41
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 16 Jun 2024
41 points (93.6% liked)
Programming
17314 readers
238 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 1 year ago
MODERATORS
no, the other way around
When B has a foreign key to A, many B records may relate to one A record. That's the many2one part.
The fact that different B records can point to different A records is irrelevant to that.
It's the same, mirrored. Or mirrored interpretation / representation to be more specific. (No logical change.)
If you had B --> A for many2one, then the foreign key relationship is still B --> A. But if you want to represent it from A perspective, you can say one2many - even though A does not hold the foreign keys.
In relational database schemata, using foreign keys on a column means the definition order is always one to one, and only through querying for the shared id will you identify the many.
Notably, we still make use of foreign keys. But because one record does not necessarily have only one FK value we don't store it in a column but have to save it in a separate table.
This association table AB_rel will then hold the foreign keys to both sides.