Reputation: 47
In an E-R Diagram, can a relationship have its own unique attribute? for example:
Entity A------[relationship]-------Entity B For example: relationship has an attribute that is underlined(aka its own unique attribute) along with the keys of the entities in the relationship to form its own key?
for example Entity A has key A, Entity B has key B, relationship has key C and Entity A and Entity B have a many-many relationship between them, therefore is the schema = R(A,B,C) with the primary key A,B, and C?
Upvotes: 2
Views: 10471
Reputation: 1
Yes, take the example having a many to many relationship between let's say invoice and items, I like to have the datetime as an attribute in the relationship, this has to be part of the primary key of the relationship. So when we model the E_R diagram we underline the attribute date or invoicedate
Upvotes: 0
Reputation: 25526
The short answer is yes, it's reasonable to have attributes associated with relationships and to have uniqueness constraints on those attributes. However, there are several varieties of ER modelling techniques, notations and conventions and between them there will be differences as to how to model that situation.
You tagged this question as database design. Not all ER models are intended to be database designs but if you are designing a database then the underlying data model of your intended database will be relevant. In a relational database, for example, entities and relationships are both implemented in the same way: as relations. So for a relational database you don't necessarily need to distinguish between attributes of an entity and attributes of a relationship because they will all become attributes of a relation schema (i.e. tables). This is something you could consider when deciding how to represent things in your diagram.
Upvotes: 1