Académique Documents
Professionnel Documents
Culture Documents
Outline
Symbols used in ER Diagram Cardinality Of a relationship ER Constraints
Keys. Single Value constraints. Foreign-key, or referential-integrity. Domain constraints. General constraints.
Types of Relationships
Types of binary relationship from entity set A to entity set B one one :<-->: an entity in A is related to at most one entity in B and vice versa many one :-->: an entity in A is related to at most one entity in B many many :--: an entity in A is related to 0 or more entities in B and vice versa
Cardinality of a relationship
A cardinality constraint between two entities A and B, specifies the number of instances of entity B that can (or must) be associated with each instance of entity A. Minimum cardinality: the minimum number of instances of one entity that may be associated with each instance of another entity. Maximum cardinality: the maximum number of instances of one entity that may be associated with each instance of another entity.
Binary Relationship
dept_code psrn
St_id location
name allotted
quarter_no quarter
Employee
address
Works-in
Department
dep_id dep_name
location
9
Ternary Relationship
dept_code psrn
Employee
address
Works-in
Department
pnam e
Project
pid
name
dep_id dep_name
location
10
Kinds of Constraints
Keys. Single Value constraints. Foreign-key, or referentialintegrity. Domain constraints. General constraints.
Constraints are part of the schema and does not depend on instance.
Keys
Primary key: An attribute (or combination of attributes) that uniquely identifies each row in relation. Composite key: A primary key that consists of more than one attribute. Foreign key: An attribute in a relation that serves as the primary key of another relation in the same database.
12
Key Constraints
emp-id emp-name dept-id dept-name
employee
works-in since-when
department
heads since-when
13
Key Constraints
Consider works_in: An employee can work in many departments;
a department can have many
employees. In contrast, each department has at most one head, according to the key constraint on head of dept.
14
Key Constraints
employee(emp_id, emp_name, ) dept(dept_id, dept_name, loc, tel_no) Participation Constraints
Does every dept have a head? If so, this is a participation constraint. The participation of depts in heads is said to be total (because every dept should have a head of dept).
15
Key Constraints
The participation of employees in heads is said to be partial (because every employee can not become a head of dept). If the participation is not total, it is called partial.
16
Key Constraints
Every dept_id value in dept table must appear in a row of the heads table (with a non-null emp_id value). key constraint is that a certain minimal subset of columns of a relation is a unique identifier for a tuple (row). The set of fields that uniquely identifies a tuple according to a key constraint is called a candidate key.
17