What Kind of Relationship is Between These Tables?

前端 未结 4 1512
不思量自难忘°
不思量自难忘° 2020-12-02 01:44

I have two tables that have foreign keys to each other\'s primary key. This DB is in French. I will translate the two tables that I want to you to understand.

4条回答
  •  遥遥无期
    2020-12-02 01:51

    What you are seeing here is most probably the most important child pattern.

    I would assume that we need to start from the standard parent-child relationship of "one kitchen employs one-or-more chefs". So we would have a foreign key in the cuisinier / chef table that contains the ID of the atelier_cuisine / kitchen where the cuisinierin question works.

    But for some reason, the kitchen must be able to point at the most important cook/chef working there. Only that numCuisinier or chefID / cookID is a poor naming of that foreign key column, as it misleads, just as it mislead us in your example. If you gave it a name like numCuisinierChef or "chef/cook in chief ID", the column name would be self-explanatory.

    But, the way the columns were named here, it could also be just the other way around: a chef/cook works in one or more kitchens, but one kitchen is his or her most important employer.

    Without a documentation or comments in the data model, you're fried, really ...

    Hope this helps rather than confuses - as the data model and the naming does ...

    Maybe one clue. MarceloBarbosa actually inspired me to that: If , in atelier_cuisine , numCuisinier is null-able, and , in cuisinier, numCuisine is NOT NULL, then atelier_cuisine is the parent, and cuisinier is the child, and vice-versa.

    Marco the Sane

提交回复
热议问题