Cardinality in DBMS

Cardinality in DBMS

Cardinality is the relationship between two or more entities (table). It shows how all the entities are connected. In DBMS, all the entities and tables are interconnected with each other. Here we will see the relation among one entity to another entity, many entities to a single entity, and many relations.

We can categories therelationship among tablesinto four types:

  • One to one
  • One to many
  • Many to one
  • Many to many

Let’s discuss all one by one:

One to one:

Relation between two entities with each other is known as one to one relation. In this relationship, one entity is related with only one another entity.

For example:Suppose we have tables named STUDENT having column “name” and STUDENT_DETAILS having column “aadhar no." Here in these two tables, each student has their aadhar no. The aadhar number of all students will be different, so each student has only one aadhar no. The relation between these two tables will be one to one.

Cardinality in DBMS

One to many:

 In this relationship, data of one row of one table compares many rows of another table.

For example, we have two tables, STUDENT and LIBRARY. In these tables, one student of table STUDENT can apply for many books in table LIBRARY. Here the relation of one student with too many books has seen.

Cardinality in DBMS

Many to one:

 In this relation, many rows of one table make relation with one row of the other table.

For example, we have two tables, STUDENT and SCHOOL. Many students relate to one school; in Figures (A, B, C, and D are the students, and 1, 2, 3, and 4 are the school name). We know that many students study in a school and thus here we will see many to one relation.

Cardinality in DBMS

Many to many:

 In this relation, many rows of one table make a relationship with many rows of another table.

For example, we have two tables, STUDENT having column ‘student name’ and SUBJECT having column 'subject name.' Here many students take many subjects, and one student can assign many subjects.

Cardinality in DBMS



ADVERTISEMENT
ADVERTISEMENT