Cardinality in DBMS

Cardinality in DBMS

 

In this article, we will learn about Cardinality in DBMS and its concepts. Cardinality can be defined in two ways one in terms of SQL and another in terms of Data Models. Here we will learn about both.

Cardinality

  • In terms of SQL, Cardinality can be defined as the distinctiveness of data values stored in a column.
    • Higher the cardinality, more is the number of unique data in the columns.
    • Lower cardinality indicates there is a higher number of repeated values in the column.
  • In terms of Data Models, Cardinality also refers to the relationship between two tables. The Relationship between the tables can be as-
    • One-to-One.
    • One-to-Many.
    • Many-to-one.
    • Many-to-Many.
Cardinality in DBMS

Understanding the concept

  • Here we consider data values as shown in figure.
  • The figure shows a Relationship between an Employee and The Department he works in.
  • As learned previously there are two Entities here : Employee and Department
  • ‘Employee’ is related to ‘Department’ by the relationship ‘Works For’.
  • Now let us understand the concept of Cardinality here.
    • The relationship of D1 in Department to E1 and E2 in  Employee can be defined as One-to-Many.
    • Similarly, The Relationship of E3 in Employee to D2 in Department can be defined as One-to-One.
Realtionship in Cardinality in DBMS
Learn more about DBMS here on this page.