0% found this document useful (0 votes)
3 views

Unit 2 Final

The document provides an overview of the Entity-Relationship (ER) Data Model, detailing its basic concepts, benefits, types of models, and phases of data modeling. It explains key components such as entities, attributes, relationships, and various types of keys essential for database design. Additionally, it discusses mapping cardinalities and participation constraints, along with examples to illustrate the concepts.

Uploaded by

yashpatil3388
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Unit 2 Final

The document provides an overview of the Entity-Relationship (ER) Data Model, detailing its basic concepts, benefits, types of models, and phases of data modeling. It explains key components such as entities, attributes, relationships, and various types of keys essential for database design. Additionally, it discusses mapping cardinalities and participation constraints, along with examples to illustrate the concepts.

Uploaded by

yashpatil3388
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 59

Dr.

Amol Pande
Computer Department
DMCE,Airoli

Unit No-2

Entity–Relationship
Data Model

Dr. Amol Pande 1


Basic Concept
• Data Model :
• Data Model is the collection of conceptual tool for describing –
• Data
• Data Schema
• Consistency constraints
• Data models are classified into following categories :

Object-Based Record based


Model Model

Object oriented Relational Hierarchical


E-R Model Network Model
model Model Model

Dr. Amol Pande 2


Basic Concept
Benefits of Data Modelling:
• Focussing on essentials :
• Aim at developing an abstract view of the system/prod/process. While ignoring the other
details.
• Example: model building external amenities are more focused than internal amenities.
• Ease of communication and understanding:
• Helps to reach to common understanding of the subject.
• Examples : Building payroll system communication is DB designer and finance officer.
• Product or process improvement:
• It helps in improvement of existing process by communication between various
stakeholders of company.
• Exploring alternatives:
• To help to find out alternative solutions to existing system.
• Example : Online entry form for student enrolment.
• Biometric attendance system for existing EMP. Dbase.

Dr. Amol Pande 3


Basic Concept
• Types of Models

• 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.

Dr. Amol Pande 4


Basic Concept
Phases of Data Modelling :
1. Gathering & Analysis of Requirement

2. Design of Database logically

3. Selection of DBMS

4. Implementation and tuning of Database.

Dr. Amol Pande 5


ER-Model
• Entity Relationship Model
• Definition:
• ER model is based on a perception of a real world that consist set of basic object
called entities and relationship among these objects.
• Entity:
• Entity is a thing or a object in the real world that is distinguishable from all other
objects.
• An Entity has a set of properties or attributes.
• Entity can be Physical or Logical
• Example:
• Student ={Rn, Name, address, mobile no} – Physical Entity
• Customer = {Ccd, Cname, Cadd} – Physical Entity
• Employee = {Eid, Ename, Eadd} – Physical Entity
• Saccount = {Acno, opdt, opbal,cramt,dbamt,bal} – Logical entity
Dr. Amol Pande 6
ER-Model
• Entity Set :
• Is the set of entities of the same type that share the same properties or
attributes.

• Entity Set
Roll Student Name Address
No
1 ABC Thane
• Student = 2 NML Vashi
3 PQR Dombivali

Dr. Amol Pande 7


ER-Model
• Attributes:
• Attributes are nothing but Characteristics or properties of object.
• Each entity has a set of attributes.
• Types of Attributes :
1. Simple attribute: which cannot be further divided into sub attributes.
Example : Rollno, Custcode, Empcode, acno…

2. Composite attribute: which can be divided into sub attributes.


Example : Cust name and Date of Birth
Cust-name DOB

F-name M-name L-name DD MM YY

Dr. Amol Pande 8


ER-Model
• Types of Attributes: Cont…

3. Single Valued attribute: which has single value for a particular entity.
Example : Rollno, Custcode, Empcode, acno…

4. Multivalued attribute: which has a set of values for a specific entity.


Example : cust_add, mobile no

5. NULL attribute : which does not have a value for an attribute or


unknown value.
Example: Commission of employee. Grace Marks.

6. Derived attribute: can be derived from the value of other attribute


Example: Age, Percentage

Dr. Amol Pande 9


ER-Model
• Relationship:
• Relationship is an association among several entities.
• Example : Customer has Account
Customer Cust-Has-Acct Account
Cust Cust-Name Cust-Add Cust-cd Ac-no Ac-no Ac-op-Date Ac-Bal.
Cd C1 A1 A1 12-05-2015 5000
C1 XYZ Thane

• 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.

C1 XYZ Thane C1 A1 A1 12-05-2015 5000


C2 ABC Vashi C2 A3 A2 25-06-2016 3000
C3 NML Dombivali C3 A2
A3 15-08-2014 2500

Dr. Amol Pande 10


ER-Model
• Degree of Relationship set:
• Unary Relationship Set:
• When one Entity set is associated with same Entity set.
• Example : Employee associated Employee
• Binary Relationship Set:
• When two different Entity set are associated .
• Example : Customer associated Account
• Ternary Relationship Set:
• When three different Entity set are associated.
• Example : Employee - Job - Branch
• N-ary Relationship Set:
• When N different Entity set are associated.

• 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

Dr. Amol Pande 12


ER-Model
• Mapping Cardinality
• One-to-One:
• An entity in ‘A’ is associated with at most one entity in ‘B’ and entity in
‘B’ is associated with at most one entity in ‘A’.
A (Entity Set) B(Entity Set)

College Principal

Cricket Team Captain

Country President

Dr. Amol Pande 13


ER-Model
• Mapping Cardinality
• One-to-Many:
• An entity in ‘A’ is associated with number of entities in ‘B’ and entity
in ‘B’ is associated with at most one entity in ‘A’.

A (Entity Set) B(Entity Set)


College Students

Cricket Team Players

Person Vehicles

Bank Employee

Professor Subject

Dr. Amol Pande 14


ER-Model
• Mapping Cardinality
• Many-to-One:
• An entity in ‘A’ is associated with at most one entity in ‘B’ and an entity in ‘B’
is associated with any number of entities in ‘A’.

A(Entity Set) B (Entity Set)


Students College

Players Cricket Team

Vehicles Person

Employee Bank

Subject Professor

Dr. Amol Pande 15


ER-Model
• Mapping Cardinality
• Many-to-Many:
• An entity in ‘A’ is associated with any number of entities in ‘B’ and an entity in
‘B’ is associated with any number of entities in ‘A’.

A(Entity Set) B (Entity Set)

Customer Account

Subject Professor

University Courses

Books Library

Dr. Amol Pande 16


ER-Model
KEYS:
• Individual entities and relationship are distinct but it is important
to distinguish entities within entity sets and relationship with
relationship sets. The concept of keys helps us to distinguish the
entities and relationship.

• Key help us to identify a particular entity within an entity set.

• 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}

Dr. Amol Pande 19


ER-Model
Primary Key :
• Primary key is a candidate key chosen by Database designer as the principal means of
identifying entities within entity set.
• Two Important Properties while selecting Primary key from candidate key.
1. Not Null
2. Unique
• Example : {Rn}
Alternate Key:
• From candidate keys, only one key gets selected as primary key, the remaining keys are
known as alternative or secondary keys.
• Example : {Email_id}
Composite Key :
• A primary key having two or more attributes is called composite key. It is a combination of
two or more attribute.
• Example: {OrderID, ProductID}
Dr. Amol Pande 20
ER-Model
• Types of Entity Set:
• 2 types of Entity set
• Strong entity set:
• An entity set which has its own primary key is called as Strong Entity set.
• Example:
• Customer = {Cust-cd} , Employee = {Emp-cd}, Student = {Sid}
• Weak entity set:
Discreminator
• An entity set which does not have its own primary key is called as Weak entity set.
Primary Key
• Example: Payment , Address
Loan-no Loan-date Loan- Loan- Pay-no Pay-date Pay-amount Pay-no Pay-date Pay-amount
Amoun type
t 1 01-01-2019 3000
L1 01-12-2018 50000 Home 1 01-01-2019 3000
2 01-02-2019 3000
L1 01-12-2018 50000 Home 2 01-02-2019 3000
3 01-03-2019 3000
L1 01-12-2018 50000 Home 3 01-03-2019 3000 1 01-01-2020 5000
L2 01-12-2019 100000 Education 1 01-01-2020 5000 2 01-02-2020 5000
L2 01-12-2019 100000 Education 2 01-02-2020 5000 1 01-03-2020 7000
L3 01-02-2020 75000 Car 1 01-03-2020 7000

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.

• Partial Participation constraint:


• When some entities of entity set participating in relationship set then it is called as Partial
participation constraint.

Loan-no Loan-date Loan- Loan- Loan-no Cust-cd Cust-cd Cust-name Cust-address


Amount type
L1 01-12-2018 50000 Home L1 C1 C1 ABC THANE

L2 01-12-2018 50000 Car L2 C4 C2 IJK VASHI

L3 01-12-2018 50000 Home L3 C3 C3 NML AIROLI


L4 01-12-2019 100000 Home L4 C4 C4 PQR DOMBIVALI
L5 01-02-2020 75000 Car L5 C1 C5 XYZ MULUND

Total Partial

Dr. Amol Pande 22


ER-Model

Dr. Amol Pande 23


ER-Model
• Entity set and its Attributes

Dr. Amol Pande 24


ER-Model
• Entity set and its Attributes (Composite attribute)

Dr. Amol Pande 25


ER-Model
• Entity set and its Attributes (All types of attributes)

Dr. Amol Pande 26


ER-Model
• Unary relationship:

Dr. Amol Pande 27


ER-Model
• Binary relationship(One to One) :

Dr. Amol Pande 28


ER-Model
• Binary relationship(One to Many) :

Dr. Amol Pande 29


ER-Model
• Binary relationship(Many to Many) :

Dr. Amol Pande 30


ER-Model
• Ternary Relationship :

Dr. Amol Pande 31


ER-Model
• Binary Relationship( strong entity set to Weak entity set)

Dr. Amol Pande 32


ER-Model
• Steps:
1. Read Problem definition carefully
2. Identify entity set(Strong and weak entity set)
3. Identity the relevant attributes(simple, composite, single, multi,…)
4. Identify key attributes
5. Find Relationship set
6. Identify mapping cardinality
7. Draw complete E-R diagram
8. Review with business user

Dr. Amol Pande 33


ER Model - Case Study 1 : Hospital

• 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

Dr. Amol Pande 35


ER Model - Case Study2 : Car-insurance company

• 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

Dr. Amol Pande 36


ER Model - Case Study 2

Dr. Amol Pande 37


ER Model - Case Study 3 : Exam

• 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

Dr. Amol Pande 38


ER Model - Case Study 3

Dr. Amol Pande 39


Effect of miscommunications in
Software Development
• Generally the business scenarios are complex in nature.
• A software application designer who is not an expert in a
particular business domain may fail to capture the exact
business requirement to build a software application.
• This is one of the prominent causes of software project
failure.
• Figure explains how miscommunications between different
users could create chaos in software development projects.

Dr. Amol Pande 40


Figure explains: Effect of miscommunications in Software
Development

Dr. Amol Pande 41


ER Model - Case Study 4 : College

• Draw an E-R model for College DB.


• A college contains many departments. Each department has multiple instructors;
one among them is the head of the department; An instructor belongs to only one
department; Each department offers multiple courses, each of which is taught by a
single instructor, an instructor can take any number of courses. A student may enroll
for many courses and each course can have any number of students offered by
departments.

Dr. Amol Pande 42


ER Model - Case Study 4

• Draw an E-R model for College DB:


• Solution
1. Identify entity set(Strong and weak entity set)
• Strong entity set
• DEPARTMENT , COURSE
• INSTRUCTOR , STUDENT

2. Identity the relevant attributes(simple, composite, single, multi,…)


• Department = {Did, Department Name ,Location}
• Course = {Cno, Course Name, Duration” and “ Prerequisite}
• Instructor = {Iid, Instructor Name, Room Number ,Telephone Number}
• Student = {Sid, Student Name, DoB}

3. Find Relationship set and Identify mapping cardinality


• Has = Department to Instructor  One to Many
• Headed By = Department to Instructor  One to One
• Offers = Department to Course  One to Many
• Taught By = Course to Instructor  Many to One
• Enrolled By = Course to Student  Many to Many

Dr. Amol Pande 43


ER Model - Case Study 4

Dr. Amol Pande 44


ER Model - Case Study 5 : Movie DB

• Draw an E-R model for Movie DB.


• Movie studio wishes to institute a data base to manage their files of movies, actor
and director. The following facts are relevant :
• Each actor has appeared in many movies. Each movie has had one director and one
or more actors. Each actor and director may have several address and mobile nos.

Dr. Amol Pande 45


ER Model - Case Study 5

Dr. Amol Pande 46


Extended E-R features:
• Specialization
• Generalization
• Aggregation

• Specialization:
• Is similar to classification.
• Example :

Dr. Amol Pande 47


Extended E-R features:
• Specialization:
• The process of designating subgroupings within an entity set is called as
specialization.
• It is represented by
• IsA : is a part of
• The idea behind Specialization is to find the subsets of entities that have few
distinguish attributes.
• Specialization is a top-down process.

Superclass
• Example :

Subclass

Dr. Amol Pande 48


Extended E-R features:
• Specialization:
• Real world Examples:

Dr. Amol Pande 49


Extended E-R features:
• Specialization:
• Real world Examples:

Dr. Amol Pande 50


Extended E-R features:
• Generalization:
• The commonality is expressed by Generalization.
• It is represented by

Or

• Generalization uses bottom-up approach where two or more lower level


entities combine together to form a higher level new entity.

• The new generalized entity can further combine together with lower level
entity to create a further higher level generalized entity.

Dr. Amol Pande 51


Extended E-R features:
• Generalization:
• Real world Examples:

Dr. Amol Pande 52


Extended E-R features:
• Constraints on Specialization/Generalization:
• Disjoint constraint:
• The disjoint constraint only applies when a superclass has more than one subclass.
• If the subclasses are disjoint, then an entity occurrence can be a member of only one of
the subclasses. (can be of only one type)
• Example:

Dr. Amol Pande 53


Extended E-R features:
• Constraints on Specialization/Generalization:
• Overlapping constraint:
• This applies when an entity occurrence may be a member of more than one subclass.(an
be subclass of any type)
• Example:

Dr. Amol Pande 54


Extended E-R features:
• Aggregation:
• Limitation of ER model is that it can not express relationship among
relationship.

• Solution is:
• Aggregation: Is an abstraction through which relationship are treated as
higher level entity set.
• Represented by

Dr. Amol Pande 55


Extended E-R features:
• Aggregation:
• Example:
1. Consider this ternary relationship between Employee, Branch and Job..

2. Now suppose we want to record Mangers for (Employee, Branch an Job)


combination.
3. Let us assume that there is an Entity set Manager.

Dr. Amol Pande 56


Extended E-R features:
• Aggregation:
• Example:
1. One of the solution is Quarter-nary relationship set.

Dr. Amol Pande 57


Extended E-R features: Case Study

Dr. Amol Pande 58


Extended E-R features: Case Study

Dr. Amol Pande 59

You might also like