Create new schemas

To try out embeds, we’ll move away slightly from the data model we’ve worked with so far and create a new Album schema. This one will use embeds, rather than associations, to handle the child records for Artist and Track. The relationships will still be the same—that is, albums will have one artist and have many tracks—but we’ll model these relationships using embeds.

We’ll create new schemas with different names to keep this approach distinct in our codebase. Let’s start with tracks.

We define embeds similarly to normal schemas, but we don’t provide a name for the source table since they belong to no particular table.

Get hands-on with 1200+ tech skills courses.