Belongs To / Has Many
Preparing your DB schema
For defining a belongs_to
and has_many
relation you need to add a foreign_key
to one of your two tables.
Let's define a Post belongs_to Author (one-to-one)
and User has_many Posts (one-to-many)
relation by adding a single foreign_key
. In this example, EzQL will generate both relations.
Resulting Model Relations
With the DB setup above, EzQL will generate the following Model Relations.
Last updated