Unit 2 Final
Unit 2 Final
Amol Pande
Computer Department
DMCE,Airoli
Unit No-2
Entity–Relationship
Data Model
• Descriptive :
• To understand the system.
• Example : School teacher may build a model to explain the scientific
concept to student.
• Prescriptive :
• Is to specify what pieces of software is suppose to do so.
• Example: Components of architecture.
• Representative :
• Is to simulate the behaviour of system.
• Example: Computer games that simulate racing of cars.
3. Selection of DBMS
• Entity Set
Roll Student Name Address
No
1 ABC Thane
• Student = 2 NML Vashi
3 PQR Dombivali
3. Single Valued attribute: which has single value for a particular entity.
Example : Rollno, Custcode, Empcode, acno…
• Relationship Set:
• It is a set relationship of same type.
Cust-cd Cust-name Cust-add Cust-cd Ac-no Ac-no Ac-op-Date Ac-Bal.
• Note : Relationships between more than two entity sets are rare. Most
relationships are binary.
Dr. Amol Pande 11
ER-Model
• Mapping Cardinality:(Type of Relationship Set)
• Express the number of entities to which another entity can be associated via a
relationship set.
• Most useful in describing binary relationship sets.
• For a binary relationship set the mapping cardinality must be one of the
following types:
-One to one
-One to many
-Many to one
-Many to many
College Principal
Country President
Person Vehicles
Bank Employee
Professor Subject
Vehicles Person
Employee Bank
Subject Professor
Customer Account
Subject Professor
University Courses
Books Library
• Super Key
• Candidate Key
• Primary Key
• Alternate Key
• Composite Key
Dr. Amol Pande 17
ER-Model
Super key:
• Is a set of one or more attributes that taken collectively allow us to
identify uniquely an entity in the entity set.
• Consider an entity Student with attributes:
• Student = {Rn, Name, Address, Email_id, Marks}
• Here
• {Rn} is a Super key .. Let us K
• {Rn, Name} is also a super Key
• {Rn, Address} is also a super Key
• {Rn, Address, Name} is also a super Key
• {Rn, Name, Address, Email_id, Marks} is also a super Key
• {Email_Id} is also a super key
• Important Point:
• If K is super key then superset of K is also Super key.
Dr. Amol Pande 18
ER-Model
Candidate key:
• Two important Properties
• Minimal of Super key is called candidate key.
• No proper subset of candidate key is super key.
• Example:
• {Rn}
• {Email_Id}
Loan Payment
Dr. Amol Pande 21
ER-Model
• Participation constraint
• Total Participation constraint:
• When all entities of entity set participate in relationship set then it is called as Total
participation constraint.
Total Partial
• Construct an E-R diagram for a hospital with a set of patients and a set of medical
doctors. Associate with each patient a log of the various tests and examinations
conducted.
• Solution
1. Identify entity set(Strong and weak entity set)
• Strong entity set
1. Doctor
2. Patient
3. Test
2. Identity the relevant attributes(simple, composite, single, multi,…)
1. Doctor = {Did, Dname, Qualification, Specialization, Experience}
2. Patient = {Ss#, name, insurance, date−admitted, date−checked−out}
3. Test = {Test_id, test-name, date, time, result}
3. Find Relationship set and Identify mapping cardinality
1. Dr−Patient = between Doctor and Patient = Many to Many
2. test−log = between Patient and Test = 1 to Many
3. performed-by =between doctor and Test = Many to Many
Dr. Amol Pande 34
ER Model - Case Study 1
• Construct an E-R diagram for a car-insurance company whose customers own one
or more cars each. Each car has associated with it zero to any number of recorded
accidents.
• Solution
1. Identify entity set(Strong and weak entity set)
• Strong entity set
1. Person
2. car
3. accident
2. Identity the relevant attributes(simple, composite, single, multi,…)
1. Person = {driver-id, name, address}
2. car= {Reg.No, year, model}
3. accident = {report-number, date, location}
3. Find Relationship set and Identify mapping cardinality
1. Owns = between Person and car = one to Many
2. Participated = between Person and Accident = manyto Many
3. Participated = between Car and Accident = Many to Many
• Consider a database used to record the marks that students get in different
exams of different course offerings. Construct an E-R diagram that models exams
as entities, and uses a ternary relationship, for the above database.
• Solution
1. Identify entity set(Strong and weak entity set)
• Strong entity set
1. student
2. course
3. exam
2. Identity the relevant attributes(simple, composite, single, multi,…)
1. student = {student-id, name, program}
2. course-offering = {course-no, year, semester, time, room}
3. Exam = { Eid, Name, Place, Time}
3. Find Relationship set and Identify mapping cardinality
1. Takes = between Student – Course – Exam = Many to Many
• Specialization:
• Is similar to classification.
• Example :
Superclass
• Example :
Subclass
Or
• The new generalized entity can further combine together with lower level
entity to create a further higher level generalized entity.
• Solution is:
• Aggregation: Is an abstraction through which relationship are treated as
higher level entity set.
• Represented by