Pooja Gupta
Pooja Gupta

Reputation: 357

Self Relationship in ER Modelling

I am trying to make an ER model in which i am confused about one of the relationships. Suppose I have an entity called order which has bunch of attributes like order_id,total price of order etc and i want to store the details of this order in another table named order details which would capture order_id,product_id,quantity,price. This second table will allow a consumer to see the details about a particular order where as first will just give a total look without any detail. After extensive researching, I still have 2 queries, please help me with them: a)Will order detail be self referencing the order entity in er diagram? I get it that order detail will be weak entity. b)Is an entity allowed to have 3+ binary relationships with other entities?

Upvotes: 0

Views: 7209

Answers (1)

reaanb
reaanb

Reputation: 10066

Based on your description, I sketched out this ER model:

order detail ER diagram

Will order detail be self referencing the order entity in er diagram?

Since order detail isn't the same thing as order, how can one "self-reference" the other?

I get it that order detail will be weak entity.

Not necessarily. In my diagram above, order detail is a relationship. We could handle it as a weak entity like so:

order details ER diagram 2

A weak entity requires a weak key (otherwise it reduces to a subtype), so I added a line item # attribute. Clearly, this model is a bit more complicated than the previous one, for little benefit.

Is an entity allowed to have 3+ binary relationships with other entities?

Yes, there is no limit on the number of relationships (binary or otherwise) that an entity can be involved in.

Upvotes: 1

Related Questions