Search code examples
databaseentity-relationship

ERM: Key attribute for relation


My question is the following: Can relations have key attributes like shown in the following figure?

For me it doesn't make sense, however I have found them like in 1. If it is possilbe, how should I "resolve" them in the relational schema?

I found a similar the question on [2] but it seems to focus on how to handle attributes during the transformation of the ERM to the relational schema.

1 https://www.wu.ac.at/fileadmin/wu/processed/csm_erm_cardinalities2_84a65dbc2b.png

[2] relationship attributes in ER diagrams


Solution

  • According to Chen in The Entity-Relationship Model - Toward a Unified View of Data, a relationship set is an association among entity sets, while an attribute is a mapping from an entity set or relationship set to a value set. This means the entities that make up the relationship must be the determinant of the attribute, so a relationship can't depend on its own attributes.

    The situation is complicated by common language use - people tend to use attribute to mean a column, which conflates attributes with value sets. Tables that represent relationship sets do have key columns, and those columns do represent attributes of the specific entity sets they represent, but they don't represent attributes of the relationship set.

    Note that in your example [1], the key "attribute" on the relationship represents a composition of the keys of ABC and XYZ, so it isn't really a distinct attribute. Normally, in ER diagrams we understand that the keys of the associated entities determine the relationship, so there's no need to indicate a key directly on the relationship shape.