Question

I'm learning for a test at school from database systems, and I'havent found similar example on the Internet and I'm not sure. What is the cardinality of following relationship ?

enter image description here

I would say 1:1. Some of my friends say that 1:M. Am I right?

I've been thinking as follows: ET1 is tightly coupled with ET2 using atr3(FK) but also has its own atr1(PK). So ET2:ET1 is 1:M. But then there ist atr1(FK) in ET2 and this relationship sounds to me like that ET2 that has ET1s can be exactly linked only to one of its ET1 so the resulting relationship should be 1:1.

What do you think ?

Thank you very much guys.

Was it helpful?

Solution 2

In the absence of further information, this relationship appears to be many:many.

A foreign key on one table linking to a primary key on another table indicates a many-to-one relationship. This means that:

  • one ET2 record can have many corresponding ET1 records, via atr3.
  • one ET1 record can have many corresponding ET2 records, via atr1.

Thus, there is a many-to-many relationship between them.

Normally, this is handled in relational models by introducing a link entity, with a compound key composed of the primary keys of the two existing entities, together with any attributes that occur solely at the link level - so here, link entity ET1_ET2 would have a compound key consisting of atr1 and atr3, while foreign keys atr3 and atr1 would then be removed from ET1 and ET2 respectively.

(Other relationships are conceivable, but would require further information to be confirmed - for example, it's possible that ET1 and ET2 are actually the same entity, involved in a Bill-Of-Materials type relationship.)

OTHER TIPS

There are two relationships. There is no single cardinality to describe two unique relationships between the same two entities.

My answer: ET2:ET1 is 1..N; ET1:ET2 is 0..N

Based on your description (mostly that ET1.atr1 is the PK), the diagram is very confusing. This is my take on the diagram - ET1.atr3 "above the line" and therefore part of a composite primary key with ET1.atr1. Since ET1.atr1 is referenced by ET2, it must be a candidate key (i.e. a ET1.atr1 value must be able to uniquely identify a single record). One entity must be inserted prior to another (obviously), so one of the two FK fields must be nullable. As ET1's FK to ET2 (ET1.atr3) is part of the composite primary key, it cannot be null. Therefore, ET2.atr1 must be nullable. The diagram shows a dashed line representing the ET1:ET2 relationship, further enforcing that this is the relationship that is 0..N

If you could clarify the scenario further I will update my answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top