Cardinality of Relationship


While creating relationship between two entities, we may often need to face the cardinality problem. This simply means that how many entities of the first set are related to how many entities of the second set. Cardinality can be of the following three types.
One-to-One
Only one entity of the first set is related to only one entity of the second set. E.g. A teacher teaches a student. Only one teacher is teaching only one student. This can be expressed in the following diagram as:

One-to-Many
Only one entity of the first set is related to multiple entities of the second set. E.g. A teacher teaches students. Only one teacher is teaching many students. This can be expressed in the following diagram as:

Many-to-One
Multiple entities of the first set are related to multiple entities of the second set. E.g.Teachers teach a student. Many teachers are teaching only one student. This can be expressed in the following diagram as:
 

Many-to-Many
Multiple entities of the first set is related to multiple entities of the second set. E.g.Teachers teach students. In any school or college many teachers are teaching many students. This can be considered as a two way one-to-many relationship. This can be expressed in the following diagram as:



In this discussion we have not included the attributes, but you can understand that they can be used without any problem if we want to.

Post a Comment

Previous Post Next Post