Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble deciding on identifying or non-identifying relationship

I've read this question: What's the difference between identifying and non-identifying relationships?

But I'm still not too sure... What I have is three tables.

  1. Users
  2. Objects
  3. Pictures

A user can own many objects and can also post many pictures per individual object. My gut feeling tells me this is an identifying relationship, because I'll need the userID in the objects table and I'll need the objectID in the pictures tables...

Or am I wrong? The explanations in the other topic limit themselves to the theoretical explanation of the way the database interprets it after it's already been coded, not how the objects are connected in real life. I'm kinda confused as to how to make the decision of identifying versus non-identifying when thinking about how I'm going to build the database.

like image 300
KdgDev Avatar asked Aug 01 '09 15:08

KdgDev


People also ask

What is non-identifying relationship example?

A non-identifying relationship is when the primary key attributes of the parent must not become primary key attributes of the child. A good example of this is a lookup table, such as a foreign key on Person.

What is a non-identifying relationship?

A non-identifying relationship is a relationship between two entities in which an instance of the child entity is not identified through its association with a parent entity, which means the child entity is not dependent on the parent entity for its identity and can exist without it.

Can a weak entity have more than one identifying relationship?

A weak entity set has one or more many-one relationships to other (supporting) entity sets.


2 Answers

Both sound like identifying relationships to me. If you have heard the terms one-to-one or one-to-many, and many-to-many, one-to- relationships are identifying relationships, and many-to-many relationships are non-identifying relationships.

  • If the child identifies its parent, it is an identifying relationship. In the link you have given, if you have a phone number, you know who it belongs to (it only belongs to one).

  • If the child does not identify its parent, it is a non-identifying relationship. In the link, it mentions states. Think of a state as a row in a table representing mood. "Happy" doesn't identify a particular person, but many people.

Edit: Other real life examples:

  • A physical address is a non-identifying relationship, because many people may reside at one address. On the other hand, an email address is (usually considered) an identifying relationship.
  • A Social Security Number is an identifying relationship, because it only belongs to one person
  • Comments on Youtube videos are identifying relationships, because they only belong to one video.
  • An original of a painting only has one owner (identifying), while many people may own reprints of the painting (non-identifying).
like image 84
Nicole Avatar answered Oct 16 '22 05:10

Nicole


I think that an easier way to visualize it is to ask yourself if the child record can exist without the parent. For example, an order line item requires an order header to exist. Thus, an order line item must have the order header identifier as part of its key and hence, this is an example of an identifying relationship.
On the other hand, telephone numbers can exist without ownership of a person, although a person may have several phone numbers. In this case, the person who owns the phone number is a non-key or non-identifying relationship since the phone numbers can exist irrespective of the owner person (hence, the phone number owner person can be null whereas in the order line item example, the order header identifier cannot be null.

like image 30
Rick Sumner Avatar answered Oct 16 '22 07:10

Rick Sumner