Cardinality In Database

Cardinality In Database: In a relational database model, the number of records in a table or relation is called cardinality in the E-R Model of the database. However, relationship types usually have certain constraints that limit the number of instance of one entity type that can be associated with each instance of another related entity type.

Therefore, the cardinality of a relationship is defined as; the number of instances of one entity type that can be associated with each instance of another related entity type.

Suppose there are two entity types A and B that are connected by a relationship R in the E-R Model of the database of same data file. If there are no cardinality constraints on R, then any number of instance A can be associated with any number of instances of B. Usually there are cardinality constraints such as,

  • If there is one-to-one relationship between A and B, then each of the instance in A will be associated with exactly one instance in B. Conversely each instance in B will be associated with exactly one instance in A.
  • If there is one-to-many relationship between A and B, then each instance in A will be associated with many instance in B. On the other hand, each instance in B will be associated with exactly one instance in A.
  • If there is many-to-many relationship between A and B, then each instance in A will be associated with many instance in B. On the other hand, each instance in B will also be associated with many instances in A.

The cardinality of one id denoted by a small vertical line ( │ ) on the relationship line, next to the first entity type or before the second entity type.

For example a department may have many teachers. On the other hand, a teacher belongs to one department. The relationship between DEPARTMENT and TEACHER is shown as