Don Nisnoni
Don Nisnoni

Reputation: 104

ERD: Will a relation between two entities only exist if entity 1 has a foreign key that identifies from the primary key entity 2?

I will make an ERD, but from some examples from the tutorials that I have read are different and they do not explain conditions so that the relationship stands between 2 entities?, Is it because their relationship in the real world is like that? or because they have interconnected keys ?

Upvotes: 0

Views: 253

Answers (1)

DataVader
DataVader

Reputation: 780

Well, imagine relations like in real life. A child, the parents and the grandparents are multiple relationships. You can set up the database to show the biological relations, so you receive an error when trying to delete a parent/grandparent or you can set up the database to show the current/cultural relations so deleting/switching a parent/grandparent would work without deleting the child.

A child may have a foreign key referring to a parent, which becomes NULL after deleting the parent or prevents the deletion entirely. Some (mostly older) databases don’t check for that, so you could end up with a child referring a non existing parent but this would be considered a corrupt data entry.

Upvotes: 1

Related Questions