Relations between entities in ER diagram: can they have a key?

294 Views Asked by At

Can a relation between entities have a key in an ER diagram?

Doing my assignment I added a primary key to a relation between two entities but the instructor didn't agree.

1

There are 1 best solutions below

0
Christophe On

Entities have a unique identity and have a primary key that uniquely identifies them. For an authoritative definition, see Chen's foundational paper of ER theory:

an entity key is a group of attributes such that the mapping from the entity set to the corresponding group of value sets is one-to-one. (...) In the case where several keys exist, we usually choose a semantically meaningful key as the entity primary key

Relationships are only defined by the entities they relate. They do not have an identity on their own, as they do not exist on their own. Hence, they should not have a key on their own:

Since a relationship is identified by the involved entities, the primary key of a relationship can be represented by the primary keys of the involved entities.

There is however an exception: the associative entity is at the same time a relationship and an entity. As it is an entity, it should have its own primary key. And as it's also a relationship, it's a relationship with its own primary key.