SlideShare a Scribd company logo
2
Most read
3
Most read
6
Most read
The Entity-Relationship Model
Database Design Process
• Requirement collection and analysis
– DB requirements and functional requirements
• Conceptual DB design using a high-level model
– Easier to understand and communicate with others
• Logical DB design (data model mapping)
– Conceptual schema is transformed from a high-level
data model into implementation data model
• Physical DB design
– Internal data structures and file organizations for DB
are specified
Overview of Database Design
• Conceptual design: (ER Model is used at this
stage.)
– What are the entities and relationships in the
enterprise?
– What information about these entities and
relationships should we store in the database?
– What are the integrity constraints or business rules
that hold?
– A database `schema’ in the ER Model can be
represented pictorially (ER diagrams).
– An ER diagram can be mapped into a relational
schema.
ER Model Basics
• Entity: Real-world object distinguishable from
other objects. An entity is described (in DB) using
a set of attributes.
• Entity Set: A collection of similar entities. E.g., all
employees.
– All entities in an entity set have the same set of
attributes. (Until we consider ISA hierarchies,
anyway!)
– Each entity set has a key.
– Each attribute has a domain.
Employees
ssn
name
lot
ER Model Basics
• Key and key attributes:
– Key: a unique value for an entity
– Key attributes: a group of one or more attributes that
uniquely identify an entity in the entity set
• Super key, candidate key, and primary key
– Super key: a set of attributes that allows to identify and
entity uniquely in the entity set
– Candidate key: minimal super key
• There can be many candidate keys
– Primary key: a candidate key chosen by the designer
• Denoted by underlining in ER attributes
Employees
ssn
name
lot
ER Model Basics (Contd.)
• Relationship: Association among two or more
entities. e.g., Jack works in Pharmacy department.
• Relationship Set: Collection of similar relationships.
– An n-ary relationship set R relates n entity sets E1 ... En;
each relationship in R involves entities e1 in E1, ..., en in En
• Same entity set could participate in different relationship sets, or in
different “roles” in same set.
lot
dname
budgetdid
since
name
Works_In DepartmentsEmployees
ssn
Reports_To
lot
name
Employees
subor-
dinate
super-
visor
ssn
Key Constraints
• Consider Works_In:
An employee can
work in many
departments; a dept
can have many
employees.
• In contrast, each dept
has at most one
manager, according
to the key
constraint on
Manages.
Many-to-Many1-to-1 1-to Many Many-to-1
dname
budgetdid
since
lot
name
ssn
ManagesEmployees Departments
Example ER
• An ER diagram represents
several assertions about the
real world. What are they?
• When attributes are added,
more assertions are made.
• How can we ensure they
are correct?
• A DB is judged correct if it
captures ER diagram
correctly.
Students
Professor teaches
Department
faculty
major
offers
Courses
enrollment
advisor
Exercises
• Is double major allowed?
• Can a student have more
than 1 advisor?
• Is joint appointment of
faculty possible?
• Can two profs share to
teach the same course?
• Can a professor teach more
than one course?
• Can a professor stay
without affiliated with a
department?
Students
Professor teaches
Department
faculty
major
offers
Courses
enrollment
advisor
Participation Constraints
• Does every department have a manager?
– If so, this is a participation constraint: the participation of
Departments in Manages is said to be total (vs. partial).
• Every Departments entity must appear in an instance of
the Manages relationship.
lot
name dname
budgetdid
since
name dname
budgetdid
since
Manages
since
DepartmentsEmployees
ssn
Works_In
Weak Entities
• A weak entity can be identified uniquely only by considering the
primary key of another (owner) entity.
– Owner entity set and weak entity set must participate in a one-to-
many relationship set (one owner, many weak entities).
– Weak entity set must have total participation in this identifying
relationship set.
lot
name
agepname
DependentsEmployees
ssn
Policy
cost
ISA (`is a’)
Hierarchies
• Overlap constraints: Can Joe be an Hourly_Emps as well as a
Contract_Emps entity? (default: disallowed; A overlaps B)
• Covering constraints: Does every Employees entity also have to
be an Hourly_Emps or a Contract_Emps entity? (default: no; A
AND B COVER C)
• Reasons for using ISA:
– To add descriptive attributes specific to a subclass.
– To identify entities that participate in a relationship.
Contract_Emps
name
ssn
Employees
lot
hourly_wages
ISA
Hourly_Emps
contractid
hours_worked As in C++, or other PLs,
attributes are inherited.
 If we declare A ISA B, every A
entity is also considered to be a B
entity.
Aggregation
• Used when we have to
model a relationship
involving (entitity sets
and) a relationship set.
– Aggregation allows us
to treat a relationship
set as an entity set for
purposes of
participation in (other)
relationships.
Aggregation vs. ternary relationship:
 Monitors is a distinct relationship,
with a descriptive attribute.
 Also, can say that each sponsorship
is monitored by at most one employee.
budgetdidpid
started_on
pbudget
dname
until
DepartmentsProjects Sponsors
Employees
Monitors
lot
name
ssn
since
Conceptual Design Using the ER Model
• Design choices:
– Should a concept be modeled as an entity or an
attribute?
– Should a concept be modeled as an entity or a
relationship?
– Identifying relationships: Binary or ternary?
Aggregation?
• Constraints in the ER Model:
– A lot of data semantics can (and should) be captured.
– But some constraints cannot be captured in ER
diagrams.
Entity vs. Attribute
• Should address be an attribute of Employees or an
entity (connected to Employees by a relationship)?
• Depends upon the use we want to make of address
information, and the semantics of the data:
• If we have several addresses per employee, address must be an
entity (since attributes cannot be set-valued).
• If the structure (city, street, etc.) is important, e.g., we want to
retrieve employees in a given city, address must be modeled as
an entity (since attribute values are atomic).
Entity vs. Attribute (Contd.)
• Works_In4 does not
allow an employee to
work in a department
for two or more periods.
• Similar to the problem of
wanting to record several
addresses for an
employee: We want to
record several values of
the descriptive attributes
for each instance of this
relationship. Accomplished
by introducing new entity
set, Duration.
name
Employees
ssn lot
Works_In4
from to
dname
budgetdid
Departments
dname
budgetdid
name
Departments
ssn lot
Employees Works_In4
Durationfrom to
Entity vs. Relationship
• First ER diagram OK if a
manager gets a separate
discretionary budget for
each dept.
• What if a manager gets a
discretionary budget
that covers all
managed depts?
– Redundancy: dbudget
stored for each dept
managed by manager.
– Misleading: Suggests
dbudget associated with
department-mgr
combination.
Manages2
name dname
budgetdid
Employees Departments
ssn lot
dbudgetsince
dname
budgetdid
DepartmentsManages2
Employees
name
ssn lot
since
Managers dbudget
ISA
This fixes the
problem!
Binary vs. Ternary Relationships
• If each policy is
owned by just 1
employee, and
each dependent is
tied to the
covering policy,
first diagram is
inaccurate.
• What are the
additional
constraints in the
2nd diagram?
agepname
DependentsCovers
name
Employees
ssn lot
Policies
policyid cost
Beneficiary
agepname
Dependents
policyid cost
Policies
Purchaser
name
Employees
ssn lot
Bad design
Better design
Binary vs. Ternary Relationships (Contd.)
• Previous example illustrated a case when two
binary relationships were better than one ternary
relationship.
• An example in the other direction: a ternary
relation Contracts relates entity sets Parts,
Departments and Suppliers, and has descriptive
attribute qty. No combination of binary
relationships is an adequate substitute:
– S “can-supply” P, D “needs” P, and D “deals-with” S
does not imply that D has agreed to buy P from S.
– How do we record qty?
Summary of Conceptual Design
• Conceptual design follows requirements analysis,
– Yields a high-level description of data to be stored
• ER model popular for conceptual design
– Constructs are expressive, close to the way people
think about their applications.
• Basic constructs: entities, relationships, and
attributes (of entities and relationships).
• Some additional constructs: weak entities, ISA
hierarchies, and aggregation.
• Note: There are many variations on ER model.
Summary of ER (Contd.)
• Several kinds of integrity constraints can be
expressed in the ER model: key constraints,
participation constraints, and overlap/covering
constraints for ISA hierarchies. Some foreign key
constraints are also implicit in the definition of a
relationship set.
– Some constraints (notably, functional dependencies)
cannot be expressed in the ER model.
– Constraints play an important role in determining the
best database design for an enterprise.
Summary of ER (Contd.)
• ER design is subjective. There are often many
ways to model a given scenario! Analyzing
alternatives can be tricky, especially for a large
enterprise. Common choices include:
– Entity vs. attribute, entity vs. relationship, binary or
n-ary relationship, whether or not to use ISA
hierarchies, and whether or not to use aggregation.
• Ensuring good database design: resulting
relational schema should be analyzed and
refined further. FD information and
normalization techniques are especially useful.
Exercise
• What can you
say about
policy of the
bank from the
ER diagram?
• What can you
say about the
policy of the
company?
balanceacct#
AccountCustAcct
name
Customer
ssn addr
deptid budget
Dept
Manages
name
Employees
ssn lot
Design Exercise
• Design a DB using ER, and sketch the resulting diagram. State any
important assumptions you made in reaching the design. Show
explicitly whether relationships are 1-1, 1-M, or N-M.
– UMW registrar’s office: It maintains data about each
class, including the instructor, students, enrollment,
time and place of the class meetings. For each student-
class pair, a grade is recorded.
– Hospital: It maintains all patients visited, including age
and address. It also keeps track of the information about
billing, visits, data, reason for visit, and treatment.

More Related Content

What's hot (20)

PPT
Lecture 01 introduction to database
emailharmeet
 
PPT
2. Entity Relationship Model in DBMS
koolkampus
 
PPTX
DBMS and its Models
AhmadShah Sultani
 
PPTX
Client server architecture
RituBhargava7
 
PPT
Database Management System Introduction
Smriti Jain
 
PPTX
Dbms database models
sanjeev kumar suman
 
PPTX
Dbms Introduction and Basics
SHIKHA GAUTAM
 
PPT
Data models
Usman Tariq
 
PDF
Database design & Normalization (1NF, 2NF, 3NF)
Jargalsaikhan Alyeksandr
 
PPTX
Odbms concepts
Dabbal Singh Mahara
 
PDF
Database System Architecture
University of Potsdam
 
PPT
data modeling and models
sabah N
 
PDF
Dbms 3: 3 Schema Architecture
Amiya9439793168
 
PPTX
Database abstraction
RituBhargava7
 
PPTX
Data and database administration(database)
welcometofacebook
 
PPTX
Ado.Net Tutorial
prabhu rajendran
 
PPT
10. XML in DBMS
koolkampus
 
PPTX
Major issues in data mining
Slideshare
 
PPTX
Deductive databases
Dabbal Singh Mahara
 
Lecture 01 introduction to database
emailharmeet
 
2. Entity Relationship Model in DBMS
koolkampus
 
DBMS and its Models
AhmadShah Sultani
 
Client server architecture
RituBhargava7
 
Database Management System Introduction
Smriti Jain
 
Dbms database models
sanjeev kumar suman
 
Dbms Introduction and Basics
SHIKHA GAUTAM
 
Data models
Usman Tariq
 
Database design & Normalization (1NF, 2NF, 3NF)
Jargalsaikhan Alyeksandr
 
Odbms concepts
Dabbal Singh Mahara
 
Database System Architecture
University of Potsdam
 
data modeling and models
sabah N
 
Dbms 3: 3 Schema Architecture
Amiya9439793168
 
Database abstraction
RituBhargava7
 
Data and database administration(database)
welcometofacebook
 
Ado.Net Tutorial
prabhu rajendran
 
10. XML in DBMS
koolkampus
 
Major issues in data mining
Slideshare
 
Deductive databases
Dabbal Singh Mahara
 

Viewers also liked (20)

PPTX
Database design concept
Shashwat Shriparv
 
PPT
Ais Romney 2006 Slides 15 Database Design Using The Rea
Sharing Slides Training
 
PPTX
Logical database design and the relational model(database)
welcometofacebook
 
PDF
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
Beat Signer
 
PDF
Database Systems - Introduction to Database Design (Chapter 4/1)
Vidyasagar Mundroy
 
PPT
Advisor Tools Presentation
Paul Freet
 
PPTX
Introduction to software engineering
Shrayas Suryakumar
 
PPTX
Catalogued and student workers database(use cases diagram)
Jennifer Polack
 
PPT
Chapter 01
ans ali raza
 
PPTX
Erd examples
Jennifer Polack
 
PPTX
Utsav Mahendra : Introduction to Database and managemnet
Utsav Mahendra
 
PPTX
Life and work of E.F. (Ted) Codd | Turing100@Persistent
Persistent Systems Ltd.
 
PPT
Unit 1 importance ofsoftengg_b.tech iii year
Preeti Mishra
 
PPTX
Agile software process
Jennifer Polack
 
PPTX
database design process
let's go to study
 
PPTX
Software process
Jennifer Polack
 
PPTX
The entity relationship model
Jane Garay
 
PDF
software engineering
Azad public school
 
PPTX
Managing your tech career
Greg Jensen
 
PDF
4 the sql_standard
Utkarsh De
 
Database design concept
Shashwat Shriparv
 
Ais Romney 2006 Slides 15 Database Design Using The Rea
Sharing Slides Training
 
Logical database design and the relational model(database)
welcometofacebook
 
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
Beat Signer
 
Database Systems - Introduction to Database Design (Chapter 4/1)
Vidyasagar Mundroy
 
Advisor Tools Presentation
Paul Freet
 
Introduction to software engineering
Shrayas Suryakumar
 
Catalogued and student workers database(use cases diagram)
Jennifer Polack
 
Chapter 01
ans ali raza
 
Erd examples
Jennifer Polack
 
Utsav Mahendra : Introduction to Database and managemnet
Utsav Mahendra
 
Life and work of E.F. (Ted) Codd | Turing100@Persistent
Persistent Systems Ltd.
 
Unit 1 importance ofsoftengg_b.tech iii year
Preeti Mishra
 
Agile software process
Jennifer Polack
 
database design process
let's go to study
 
Software process
Jennifer Polack
 
The entity relationship model
Jane Garay
 
software engineering
Azad public school
 
Managing your tech career
Greg Jensen
 
4 the sql_standard
Utkarsh De
 
Ad

Similar to Database design (20)

PPT
Datastage database design and data modeling ppt 4
Vibrant Technologies & Computers
 
PPT
The entity relationship model
yash patel
 
PPTX
Conceptual design & ER Model.pptx
AvinashChoure2
 
PPT
Unit02 dbms
arnold 7490
 
PPSX
Cn presentation on the topic called as re modelling
g30162363
 
PPTX
Database part3-
Taymoor Nazmy
 
PPT
Ch2 er model in DBMS
SurajBhattarai15
 
PDF
2_EntityRelationship-Model-241-trang-1.pdf
chang465730
 
PDF
ER diagram is created based on three principal components: entities, attribut...
athuathul507
 
PPTX
Conceptual Data Modeling
Dr. Thippeswamy S.
 
PPTX
unit 1 Entity Relationship Modelling.pptx
AmolJoglekar5
 
PPTX
database_design_presentation, data base design presenttion
ahtms257
 
PPTX
lecture-4-Data Base Mangement System and its types
DimpyJindal4
 
PPTX
ERD.pptxasdasdasdasdasdasdsssaaasdasdasd
zmulani8
 
PPTX
ch3 final.pptx
munnamicheal
 
PDF
Unit 2 DBMS
DhivyaSubramaniyam
 
DOCX
Chapter-3 Data Modeling Using the Entity-Relationship Model
Raj vardhan
 
PPTX
Entity Relationship Model
Slideshare
 
PPTX
DBMS_Data Model,Keys,Attributes,Relationship.pptx
DrThenmozhiKarunanit
 
PPTX
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
Mustafa Kamel Mohammadi
 
Datastage database design and data modeling ppt 4
Vibrant Technologies & Computers
 
The entity relationship model
yash patel
 
Conceptual design & ER Model.pptx
AvinashChoure2
 
Unit02 dbms
arnold 7490
 
Cn presentation on the topic called as re modelling
g30162363
 
Database part3-
Taymoor Nazmy
 
Ch2 er model in DBMS
SurajBhattarai15
 
2_EntityRelationship-Model-241-trang-1.pdf
chang465730
 
ER diagram is created based on three principal components: entities, attribut...
athuathul507
 
Conceptual Data Modeling
Dr. Thippeswamy S.
 
unit 1 Entity Relationship Modelling.pptx
AmolJoglekar5
 
database_design_presentation, data base design presenttion
ahtms257
 
lecture-4-Data Base Mangement System and its types
DimpyJindal4
 
ERD.pptxasdasdasdasdasdasdsssaaasdasdasd
zmulani8
 
ch3 final.pptx
munnamicheal
 
Unit 2 DBMS
DhivyaSubramaniyam
 
Chapter-3 Data Modeling Using the Entity-Relationship Model
Raj vardhan
 
Entity Relationship Model
Slideshare
 
DBMS_Data Model,Keys,Attributes,Relationship.pptx
DrThenmozhiKarunanit
 
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
Mustafa Kamel Mohammadi
 
Ad

More from Jennifer Polack (20)

PPTX
Trainer use cases
Jennifer Polack
 
PPTX
Umw training program
Jennifer Polack
 
PPTX
Classroom scheduler update
Jennifer Polack
 
PPTX
Temperature data analyzer requirements
Jennifer Polack
 
PPTX
Training Programming Description- Morning Section
Jennifer Polack
 
PPTX
Training Programming Description- Afternoon Section
Jennifer Polack
 
PDF
Cataloged and student workers database
Jennifer Polack
 
PPTX
Temperature Analyzer Project
Jennifer Polack
 
PPTX
System Modelling
Jennifer Polack
 
PPTX
What is software engineering
Jennifer Polack
 
PPTX
Requirements engineering
Jennifer Polack
 
PPTX
Chapter 11
Jennifer Polack
 
PPTX
Chapter 10
Jennifer Polack
 
PPTX
Chapter 9
Jennifer Polack
 
PPTX
Ccsc 2015 panel
Jennifer Polack
 
PPTX
Chapter 8
Jennifer Polack
 
PPTX
Chapter 6
Jennifer Polack
 
PPTX
Erd practice exercises
Jennifer Polack
 
PPTX
Ch04
Jennifer Polack
 
PPTX
Chapter 2 group quiz
Jennifer Polack
 
Trainer use cases
Jennifer Polack
 
Umw training program
Jennifer Polack
 
Classroom scheduler update
Jennifer Polack
 
Temperature data analyzer requirements
Jennifer Polack
 
Training Programming Description- Morning Section
Jennifer Polack
 
Training Programming Description- Afternoon Section
Jennifer Polack
 
Cataloged and student workers database
Jennifer Polack
 
Temperature Analyzer Project
Jennifer Polack
 
System Modelling
Jennifer Polack
 
What is software engineering
Jennifer Polack
 
Requirements engineering
Jennifer Polack
 
Chapter 11
Jennifer Polack
 
Chapter 10
Jennifer Polack
 
Chapter 9
Jennifer Polack
 
Ccsc 2015 panel
Jennifer Polack
 
Chapter 8
Jennifer Polack
 
Chapter 6
Jennifer Polack
 
Erd practice exercises
Jennifer Polack
 
Chapter 2 group quiz
Jennifer Polack
 

Recently uploaded (20)

PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
DOCX
A summary of SPRING SILKWORMS by Mao Dun.docx
maryjosie1
 
PPTX
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PDF
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
A summary of SPRING SILKWORMS by Mao Dun.docx
maryjosie1
 
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
community health nursing question paper 2.pdf
Prince kumar
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 

Database design

  • 2. Database Design Process • Requirement collection and analysis – DB requirements and functional requirements • Conceptual DB design using a high-level model – Easier to understand and communicate with others • Logical DB design (data model mapping) – Conceptual schema is transformed from a high-level data model into implementation data model • Physical DB design – Internal data structures and file organizations for DB are specified
  • 3. Overview of Database Design • Conceptual design: (ER Model is used at this stage.) – What are the entities and relationships in the enterprise? – What information about these entities and relationships should we store in the database? – What are the integrity constraints or business rules that hold? – A database `schema’ in the ER Model can be represented pictorially (ER diagrams). – An ER diagram can be mapped into a relational schema.
  • 4. ER Model Basics • Entity: Real-world object distinguishable from other objects. An entity is described (in DB) using a set of attributes. • Entity Set: A collection of similar entities. E.g., all employees. – All entities in an entity set have the same set of attributes. (Until we consider ISA hierarchies, anyway!) – Each entity set has a key. – Each attribute has a domain. Employees ssn name lot
  • 5. ER Model Basics • Key and key attributes: – Key: a unique value for an entity – Key attributes: a group of one or more attributes that uniquely identify an entity in the entity set • Super key, candidate key, and primary key – Super key: a set of attributes that allows to identify and entity uniquely in the entity set – Candidate key: minimal super key • There can be many candidate keys – Primary key: a candidate key chosen by the designer • Denoted by underlining in ER attributes Employees ssn name lot
  • 6. ER Model Basics (Contd.) • Relationship: Association among two or more entities. e.g., Jack works in Pharmacy department. • Relationship Set: Collection of similar relationships. – An n-ary relationship set R relates n entity sets E1 ... En; each relationship in R involves entities e1 in E1, ..., en in En • Same entity set could participate in different relationship sets, or in different “roles” in same set. lot dname budgetdid since name Works_In DepartmentsEmployees ssn Reports_To lot name Employees subor- dinate super- visor ssn
  • 7. Key Constraints • Consider Works_In: An employee can work in many departments; a dept can have many employees. • In contrast, each dept has at most one manager, according to the key constraint on Manages. Many-to-Many1-to-1 1-to Many Many-to-1 dname budgetdid since lot name ssn ManagesEmployees Departments
  • 8. Example ER • An ER diagram represents several assertions about the real world. What are they? • When attributes are added, more assertions are made. • How can we ensure they are correct? • A DB is judged correct if it captures ER diagram correctly. Students Professor teaches Department faculty major offers Courses enrollment advisor
  • 9. Exercises • Is double major allowed? • Can a student have more than 1 advisor? • Is joint appointment of faculty possible? • Can two profs share to teach the same course? • Can a professor teach more than one course? • Can a professor stay without affiliated with a department? Students Professor teaches Department faculty major offers Courses enrollment advisor
  • 10. Participation Constraints • Does every department have a manager? – If so, this is a participation constraint: the participation of Departments in Manages is said to be total (vs. partial). • Every Departments entity must appear in an instance of the Manages relationship. lot name dname budgetdid since name dname budgetdid since Manages since DepartmentsEmployees ssn Works_In
  • 11. Weak Entities • A weak entity can be identified uniquely only by considering the primary key of another (owner) entity. – Owner entity set and weak entity set must participate in a one-to- many relationship set (one owner, many weak entities). – Weak entity set must have total participation in this identifying relationship set. lot name agepname DependentsEmployees ssn Policy cost
  • 12. ISA (`is a’) Hierarchies • Overlap constraints: Can Joe be an Hourly_Emps as well as a Contract_Emps entity? (default: disallowed; A overlaps B) • Covering constraints: Does every Employees entity also have to be an Hourly_Emps or a Contract_Emps entity? (default: no; A AND B COVER C) • Reasons for using ISA: – To add descriptive attributes specific to a subclass. – To identify entities that participate in a relationship. Contract_Emps name ssn Employees lot hourly_wages ISA Hourly_Emps contractid hours_worked As in C++, or other PLs, attributes are inherited.  If we declare A ISA B, every A entity is also considered to be a B entity.
  • 13. Aggregation • Used when we have to model a relationship involving (entitity sets and) a relationship set. – Aggregation allows us to treat a relationship set as an entity set for purposes of participation in (other) relationships. Aggregation vs. ternary relationship:  Monitors is a distinct relationship, with a descriptive attribute.  Also, can say that each sponsorship is monitored by at most one employee. budgetdidpid started_on pbudget dname until DepartmentsProjects Sponsors Employees Monitors lot name ssn since
  • 14. Conceptual Design Using the ER Model • Design choices: – Should a concept be modeled as an entity or an attribute? – Should a concept be modeled as an entity or a relationship? – Identifying relationships: Binary or ternary? Aggregation? • Constraints in the ER Model: – A lot of data semantics can (and should) be captured. – But some constraints cannot be captured in ER diagrams.
  • 15. Entity vs. Attribute • Should address be an attribute of Employees or an entity (connected to Employees by a relationship)? • Depends upon the use we want to make of address information, and the semantics of the data: • If we have several addresses per employee, address must be an entity (since attributes cannot be set-valued). • If the structure (city, street, etc.) is important, e.g., we want to retrieve employees in a given city, address must be modeled as an entity (since attribute values are atomic).
  • 16. Entity vs. Attribute (Contd.) • Works_In4 does not allow an employee to work in a department for two or more periods. • Similar to the problem of wanting to record several addresses for an employee: We want to record several values of the descriptive attributes for each instance of this relationship. Accomplished by introducing new entity set, Duration. name Employees ssn lot Works_In4 from to dname budgetdid Departments dname budgetdid name Departments ssn lot Employees Works_In4 Durationfrom to
  • 17. Entity vs. Relationship • First ER diagram OK if a manager gets a separate discretionary budget for each dept. • What if a manager gets a discretionary budget that covers all managed depts? – Redundancy: dbudget stored for each dept managed by manager. – Misleading: Suggests dbudget associated with department-mgr combination. Manages2 name dname budgetdid Employees Departments ssn lot dbudgetsince dname budgetdid DepartmentsManages2 Employees name ssn lot since Managers dbudget ISA This fixes the problem!
  • 18. Binary vs. Ternary Relationships • If each policy is owned by just 1 employee, and each dependent is tied to the covering policy, first diagram is inaccurate. • What are the additional constraints in the 2nd diagram? agepname DependentsCovers name Employees ssn lot Policies policyid cost Beneficiary agepname Dependents policyid cost Policies Purchaser name Employees ssn lot Bad design Better design
  • 19. Binary vs. Ternary Relationships (Contd.) • Previous example illustrated a case when two binary relationships were better than one ternary relationship. • An example in the other direction: a ternary relation Contracts relates entity sets Parts, Departments and Suppliers, and has descriptive attribute qty. No combination of binary relationships is an adequate substitute: – S “can-supply” P, D “needs” P, and D “deals-with” S does not imply that D has agreed to buy P from S. – How do we record qty?
  • 20. Summary of Conceptual Design • Conceptual design follows requirements analysis, – Yields a high-level description of data to be stored • ER model popular for conceptual design – Constructs are expressive, close to the way people think about their applications. • Basic constructs: entities, relationships, and attributes (of entities and relationships). • Some additional constructs: weak entities, ISA hierarchies, and aggregation. • Note: There are many variations on ER model.
  • 21. Summary of ER (Contd.) • Several kinds of integrity constraints can be expressed in the ER model: key constraints, participation constraints, and overlap/covering constraints for ISA hierarchies. Some foreign key constraints are also implicit in the definition of a relationship set. – Some constraints (notably, functional dependencies) cannot be expressed in the ER model. – Constraints play an important role in determining the best database design for an enterprise.
  • 22. Summary of ER (Contd.) • ER design is subjective. There are often many ways to model a given scenario! Analyzing alternatives can be tricky, especially for a large enterprise. Common choices include: – Entity vs. attribute, entity vs. relationship, binary or n-ary relationship, whether or not to use ISA hierarchies, and whether or not to use aggregation. • Ensuring good database design: resulting relational schema should be analyzed and refined further. FD information and normalization techniques are especially useful.
  • 23. Exercise • What can you say about policy of the bank from the ER diagram? • What can you say about the policy of the company? balanceacct# AccountCustAcct name Customer ssn addr deptid budget Dept Manages name Employees ssn lot
  • 24. Design Exercise • Design a DB using ER, and sketch the resulting diagram. State any important assumptions you made in reaching the design. Show explicitly whether relationships are 1-1, 1-M, or N-M. – UMW registrar’s office: It maintains data about each class, including the instructor, students, enrollment, time and place of the class meetings. For each student- class pair, a grade is recorded. – Hospital: It maintains all patients visited, including age and address. It also keeps track of the information about billing, visits, data, reason for visit, and treatment.

Editor's Notes

  • #2: The important issue of how to map from ER diagrams to relational tables is deferred until the relational model and the integrity constraints it supports have been introduced. ER to relational mapping, together with a discussion of the related SQL commands, is discussed in Chapter 3.
  • #5: The slides for this text are organized into several modules. Each lecture contains about enough material for a 1.25 hour class period. (The time estimate is very approximate--it will vary with the instructor, and lectures also differ in length; so use this as a rough guideline.) This covers Lectures 1 and 2 (of 6) in Module (5). Module (1): Introduction (DBMS, Relational Model) Module (2): Storage and File Organizations (Disks, Buffering, Indexes) Module (3): Database Concepts (Relational Queries, DDL/ICs, Views and Security) Module (4): Relational Implementation (Query Evaluation, Optimization) Module (5): Database Design (ER Model, Normalization, Physical Design, Tuning) Module (6): Transaction Processing (Concurrency Control, Recovery) Module (7): Advanced Topics
  • #6: The slides for this text are organized into several modules. Each lecture contains about enough material for a 1.25 hour class period. (The time estimate is very approximate--it will vary with the instructor, and lectures also differ in length; so use this as a rough guideline.) This covers Lectures 1 and 2 (of 6) in Module (5). Module (1): Introduction (DBMS, Relational Model) Module (2): Storage and File Organizations (Disks, Buffering, Indexes) Module (3): Database Concepts (Relational Queries, DDL/ICs, Views and Security) Module (4): Relational Implementation (Query Evaluation, Optimization) Module (5): Database Design (ER Model, Normalization, Physical Design, Tuning) Module (6): Transaction Processing (Concurrency Control, Recovery) Module (7): Advanced Topics