Problem Statement
ER diagram is a graphical representation showing various tables and the relationships between them. ER diagram we can reduce the number of databases.
One-to-One Cardinality
Let us consider the following one-to-one Cardinality diagram-
In this ER diagram, employees can Work for one company, but a company can have many such employees. The above ER diagram represents 3 entities -
- Employee entity has 2 attributes namely - emp_id and emp_name. emp_id is the primary key
- Company entity has 2 attributes namely- emp_id and cmp_name. cmp_id is the primary key
- We cannot use cmp_id as the primary key because multiple employees can work for the same cmp_id. However, we can combine the Employee and Work tables. Therefore, at least 2 tables are required in a one-to-many cardinality scenario.
Many-to-Many Cardinality
Let us consider the one-to-many cardinality of the following diagram -
In this ER diagram , employees can work for multiple companies. A company can have many such employees. The above ER diagram represents 3 entities -
- Employee entity has 2 attributes namely - emp_id and emp_name. emp_id is the primary key
- Company entity has 2 attributes namely- emp_id and cmp_name. cmp_id is the primary key
- Unlike the previous example, the worksheet cannot be merged with Employee or Company. If we try to merge it, redundant data will be created. So at least 2 tables are required in many to many cardinality scenario
The above is the detailed content of Minimization of ER diagrams. For more information, please follow other related articles on the PHP Chinese website!