Relationships in DBMS
DefinitionA relationship is defined as an association among several entities.
Relationship Set
A set of relationships of similar type is called a relationship set. Like entities, a relationship too can have attributes. These attributes are called descriptive attributes.
Mapping Cardinalities:
express the number of entities to which another entity can be associated via a relationship. For binary relationship sets between entity sets A and B, the mapping cardinality must be one of:
One-to-one: An entity in A is associated with at most one entity in B, and an entity in B is associated with at most one entity in A.
One-to-many: An entity in A is associated with any number in B. An entity in B is associated with at most one entity in A.
Many-to-one: An entity in A is associated with at most one entity in B. An entity in B is associated with any number in A.
Many-to-many: Entities in A and B are associated with any number from each other.
The appropriate mapping cardinality for a particular relationship set depends on the real world being modeled.
Degree of a Relationship Set
The number of entity sets that participate in a relationship set is termed as the degree of that relationship set. Thus,
DegreeDegree of a relationship set = Number of entity sets participating in a relationship set
Types of Relationship Sets
On the basis of degree of a relationship set, a relationship set can be classified into the following types-
- Unary relationship set
- Binary relationship set
- Ternary relationship set
Unary Relationship Set
Unary relationship set is a relationship set where only one entity set participates in a relationship set.
Binary Relationship Set
Binary relationship set is a relationship set where two entity sets participate in a relationship set.
Ternary Relationship Set
Ternary relationship set is a relationship set where three entity sets participate in a relationship set.
Participation Constraints
Total Participation of an Entity set
Total participation of an entity set represents that each entity in entity set must have at least one relationship in a relationship set. It is also called mandatory participation. Total participation is represented using a double line between the entity set and relationship set.
Partial participation of an Entity Set
Partial participation of an entity set represents that each entity in the entity set may or may not participate in the relationship instance in that relationship set. It is also called as optional participation. Partial participation is represented using a single line between the entity set and relationship set.