Search⌘ K

Introduction to Polymorphic Associations

Explore how to implement polymorphic associations in Ecto for Elixir applications. Understand traditional approaches, why Ecto differs, and master three strategies to associate a single record type with multiple tables.

Add a new feature

Let’s say we wanted to add a new feature to our MusicDB application that would allow us to add notes to our album records. These notes could be anything like metadata about the album (producer, engineer, and so on) or maybe even our comments.

Our first instinct might be to add a “notes” column to the albums ...