Introduction to Embedded Schemas
Learn about embedded schemas.
We'll cover the following
Embedded Schemas
Embedded schemas are an alternative to using associations. Unlike regular associations, embedded schemas are stored on the same record as the parent schema, rather than a separate table. They are embedded in the parent schema.
Choosing embedded schemas (or embeds) over associations has advantages in some use cases, but working with them is slightly different.
What we’ll learn
In this chapter, we’ll go over:
- How to create and manage embeds.
- Discuss why we might (or might not) want to use them.
Please note that the examples in this chapter will not work with MySQL. At the database level, we’ll be using the array
column type to store the embedded “has many” relationships, and as of this writing, MySQL does not support arrays without jumping through a few extra hoops. To keep the examples clearer, we’re taking an approach that only works with Postgres.
Get hands-on with 1400+ tech skills courses.