What is a many to one relationship?
In database design many to one (or one to many) refers to a relationship between one or more entities where a single entity can have many entities connected.
Let’s make an example. Consider two entities: Mother and Daughter. As we know from real life, these two entities are most of the times connected like so:
Every Daughter has one Mother
One Mother can have many Daughters
So we have a many to one here where many is the Daughter and one is the Mother.
On the Mother side you can see two lines which stand for one and only one. That’s the “one side” of the relationship. On the Daughter side instead you can see the crow’s foot and a circle.
The circle means optional, that is, there could be zero, one, or many Daughters. Technically a Mother should have at least one Daughter to qualify for her status, but I wanted to show you the circle and I took this liberty.
A crow’s foot with a straight line on top instead means at least one, or many, that is, the many side of the relationship must not be empty.
Now, after modelling your database with an Entity Relationship Diagram it’s time to write actual SQL instructions. But these days you don’t want to do that by hand.
Nevertheless it’s important to have a basic knowledge of how many to one is implemented in practice. Let’s see.

#django #many to one in django

Understanding many to one in Django
1.10 GEEK