Cardinality and Participation
Cardinality and Participation
Cardinality and Participation
Participation
Constraint in DBMS
Relationship Constraints
We can distinguish two main types of relationship constraints:
•Cardinality constraints
•Participation constraint
Requirements for analysis
Requirement Analysis:
•Every employee work for one department
•An department can have many employees
•New department need not have employee
Degree:
Every Department should have a manager & only one employee manages a department.
An Employee can manage only one department
Relationship
Cardinality
The term cardinality actually has two different meanings depending on the context of
it’s usage – one meaning is in the context of Data modeling and the other meaning is in
the context of SQL statements.
In The Context Of Data Modeling
It simply refers to the relationship that one table can have with another
table
Employee belongs to the department, some of the employees are new and having no department. An
employee is not belongs to more than one department at the same time.
Employee salary is maintained on monthly basis. Therefore new employee might not have the
salaries for the current month.
Every employee participating in a team. Each employee participate in a single team.
These teams are managed by the employees, an employee can manage the single team.
Cardinality in SQL
Cardinality refers to the uniqueness of data contained in a column. If a column has a lot of duplicate
data (e.g. a column that stores either "true" or "false"),it has low cardinality, but if the values are highly
unique (e.g. Social Security numbers), it has high cardinality
Cardinality in SQL
For example,
let’s say we have a table with a “Gender” column which has only two possible
values of “Male” and “Female”.
Then, that “Gender” column would have a cardinality of 2, because there are only
two unique values that could possibly appear in that column .
Cardinality in SQL
Let’s say that we have a primary key column on a table with 10,000 rows. What do you think the
cardinality of that column would be?
Primary key: It is a key in a relational database that is unique for each record.
Participation Constraint