Reputation: 15
ERD from Wikipedia:
I'm confused to distinguish "has" and "contains" relationship in ERD, what's the difference between them?
Upvotes: 1
Views: 4665
Reputation: 10064
With regards to the linked diagram from Wikipedia, both Has
and Contains
are one-to-many relationships (1..n) with total participation of Character
in the relationship (double association line). Total participation means every Character
must be related to an Account
and a Region
.
However, the Has
relationship is marked as an identifying relationship (double-bordered diamond) and Character
is marked as a weak entity set (double-bordered rectangle). This means that the identifying attributes of Character
include the identifying attributes of Account
. Character
has a weak key CharName
, which must be combined with AcctName
to fully identify a Character
. In other words, the primary key of the Character
table will be composite: AcctName, CharName
.
Note that these comments apply to the example ERD, not to ERD in general. Has
and Contains
aren't types of relationships - in general, a relationship can be called anything and have any combination of the features available in ER theory.
Also, see my answer to Is optionality (mandatory, optional) and participation (total, partial) are same?
Upvotes: 4