Professional Documents
Culture Documents
Co1 Session4
Co1 Session4
Session - 4
To familiarize students with the basic concept of Constraint types and Relationships in Entity Relationship (ER) Diagrams.
INSTRUCTIONAL OBJECTIVES
•Understand that what Constraint types and Relationships used for Data Modelling.
LEARNING OUTCOMES
Constraints in an Entity-Relationship (ER) model are used to define rules that the
data in the database must follow. There are several types of constraints in an ER
model, including:
1. Entity Integrity Constraints: Entity integrity constraints ensure that each row or
instance in a table represents a unique entity by enforcing primary key
constraints. A primary key constraint requires that each entity in a table has a
unique identifier that can be used to identify it uniquely.
• Check Constraints:
Check constraints specify a condition that must be true for each row in a table.
For example, a check constraint can specify that the value of a column must be
greater than zero or that the sum of values in two columns must be less than a
certain value.
• For example, a business rule constraint can specify that a customer must have a
valid credit card to make a purchase.
Relationship
relationship
8
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Relationship - example
Avinash
DBMS
Balaji
Chandan
Java
Dinesh
Student
Course
Entity enrolls_for
Entity
relationship
9
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Relationship Type
• A relationship type between two entities defines the set of all
associations between these entities
relationship
Works_for
Faculty Department
Enrolls_for
Student Course
10
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Avinash
DBMS
Balaji
Chandan
Java
Dinesh
Student
Course
Entity enrolls_for
Entity
relationship
11
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Relationship instance
• Each instance of the relationship between members of these
entity types is called a relationship instance
Dr. Guruprasad
CSE
Dr. Umadevi
Dr. Ashok
Faculty
Entity Department
Works_for
Entity
relationship
12
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Relationship Set
• An Relationship Set is a collection of relationships all
belonging to one relationship type.
Here relationship set, has 4
relationships
Avinash DBMS
Balaji
Chandan Java
Dinesh
Student
enrolls_for Course
Entity
relationship Entity
13
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Relationship Degree
14
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
15
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Dr. Guruprasad
CSE
Dr. Umadevi
Dr. Indiramma
ISE
Dr. Ashok
Faculty
Department
Entity Works_for
Entity
relationship
19
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Ternary Relationship -example
• Ternary Relationship: Degree Three, three entities are participating
Micro Systems
Pvt. Ltd
Keyboard
Project
Part supplies
Entity
Entity relationship
20
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Keyboard
Project
Part supplies
Entity
Entity relationship
21
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
22
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Cardinality Ratios
• Cardinality is a constraint on a relationship specifying
the number of entity instances that a specific entity
may be related to via the relationship.
One to One:
One entity from entity set A can be associated with at most one
entity of entity set B and vice versa.
23
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
24
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Dr. Guruprasad
CSE
Faculty Department
Heads
Entity Entity
relationship
25
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
26
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
27
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Entity A N R M Entity B
28
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
29
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Participation Constraint
• Minimum number of relationship instance that each entity can
participate in.
30
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Participation Constraint
Example
31
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
ER Diagram Symbols
Relationship
32
CREATED BY K. VICTOR BABU
Exercise- Draw an ER diagram
33
CREATED BY K. VICTOR BABU
ER diagram- Answer
34
CREATED BY K. VICTOR BABU
SUMMARY
• Entity integrity and referential integrity constraints ensure that each row or
instance in a table represents a unique entity and that the relationships between
entities are valid, respectively.
• Domain constraints specify the allowable values for a column, while check
constraints specify a condition that must be true for each row in a table.
• Business rules constraints define the rules that govern the behavior of the
organization or business.
CREATED BY K. VICTOR BABU
SUMMARY (Cont’ d)
• ER modeling is an iterative process, meaning that the ERD can be refined and
updated as the requirements of the database change.
• In a one-to-many relationship, each entity in the first set can be related to many
entities in the second set, but each entity in the second set can only be related to
one entity in the first set.
• In a many-to-many relationship, each entity in the first set can be related to many
entities in the second set, and each entity in the second set can be related to
many entities in the first set. To represent a many-to-many relationship, a bridge
or junction entity is required to link the two sets of entities.
1. Which of the following constraint types ensures that each row or instance in a table represents a
unique entity?
2. In an ER model, which of the following relationship types requires a bridge or junction entity to link
the two sets of entities?
1. Explain the difference between entity integrity and referential integrity constraints in an ER model.
Provide an example of each type of constraint.
2. Discuss the importance of domain constraints in an ER model. How do domain constraints help to
ensure the accuracy and consistency of data in a database? Provide an example of a domain
constraint.
3. Describe the different types of relationships in an ER model, including one-to-one, one-to-many, and
many-to-many relationships. When would you use each type of relationship, and how do they affect
the structure and organization of the database?
4. Explain the role of check constraints in an ER model. How can check constraints help to ensure that
data in a database is accurate and consistent? Provide an example of a check constraint.
5. Discuss the importance of business rules constraints in an ER model. How do business rules
constraints help to ensure that the database supports the needs and goals of the organization or
business? Provide an example of a business rule constraint.
Reference Books:
1. "Database System Concepts" by Abraham Silberschatz, Henry F. Korth, and S. Sudarshan.
2. "Database Management Systems" by Raghu Ramakrishnan and Johannes Gehrke.
3. "Fundamentals of Database Systems" by Ramez Elmasri and Shamkant Navathe.
Team – DBMS