I
I
Ivan Melnikov2021-11-04 13:23:23
MySQL
Ivan Melnikov, 2021-11-04 13:23:23

What is the fundamental difference between identifying and non-identifying relationships?

In an identity relationship, the primary key of the parent table becomes part of the primary key in the child table. This is done so that a record in the child table cannot exist on its own without a reference to an existing record in the parent table. But what prevents us from not making the foreign key in the child table part of the primary key, but simply making it NOT NULL? Then the record in the child table will also not be able to exist without a link to an existing record in the parent table.
In the ER diagram below, the Phone_1 and Phone_2 tables should, in my opinion, be completely equivalent. Or am I not understanding something?
6183b47a9f6f6086571860.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vindicar, 2021-11-04
@Vindicar

Well, suppose they are not completely equivalent.
In Phone_1 id must be unique for each entry. So if you want to switch an entry in Phone_1 from one Employee to another, you can always do it for sure. This can be interpreted as "the entries in Phone_1 exist on their own, despite the mandatory association with Employee".
In Phone_2 id must be unique among records with the same Employee_id. Those. their combination must be unique. When trying to switch a record in Phone_2 from one Employee to another Employee, there is a risk of an id collision. This can be interpreted as "The entries in Phone_1 exist strictly in the context of Employee, and their own id's only make sense in the context given by Employee_id." Those. Employee_id becomes a kind of "namespace".

C
ComodoHacker, 2021-11-04
@ComodoHacker

An identifying/non-identifying relationship is a logical model concept.
And in the physical model, they can be implemented in different ways. Now composite PKs are almost never used.
So nothing gets in the way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question