SlideShare a Scribd company logo
1 of 73
Download to read offline
Database Technology
Entity Relationship Models
Heiko Paulheim
3/9/22 Heiko Paulheim 2
Previously on Database Technology
• Introduction to Relational Databases
– A standard model for storing data
– Using relations/tables
• Introduction to SQL
– Creating and changing tables
– Reading and writing data into tables
3/9/22 Heiko Paulheim 3
Today
• Designing databases
– i.e., how to get from your customer’s requirements…
– ...to a set of tables and attributes
3/9/22 Heiko Paulheim 4
Outline
• Design Process
• Modeling
• Constraints
• E-R Diagrams
• Design Issues
• Weak Entity Sets
• Extended E-R Features
• Reduction to Relation Schemas
• Comparison UML
3/9/22 Heiko Paulheim 5
Database Design
• Initial phase: requirements engineering
– characterize fully the data needs of the prospective database users
– which data needs to be stored?
• ...and in which volumes?
– which queries should be answered?
• Conceptual schema
– which types of entities and relations exist?
– what attributes do they have?
3/9/22 Heiko Paulheim 6
Database Design
• Final phase: from a conceptual to physical data model
– Logical Design: find a “good” collection of relation schemas
• Business decision – What attributes should we record in the
database?
• Computer Science decision – What relation schemas should we
have and how should the attributes be distributed among the
various relation schemas?
– Physical Design – Deciding on the physical layout of the database
3/9/22 Heiko Paulheim 7
Database Design Approaches
• Entity Relationship Model (today)
– Models an enterprise as a collection of entities and relationships
– Entity: a “thing” or “object” in the enterprise that is distinguishable from
other objects
• Described by a set of attributes
– Relationship: an association among several entities
– Represented diagrammatically by an entity-relationship diagram
• Normalization Theory (next lecture)
– Formalize what designs are bad, and test for them
3/9/22 Heiko Paulheim 8
Entity Relationship Model
• Dates back to the 1970s
– Chen, Peter Pin-Shan: The Entity–Relationship Model –
Toward A Unified View of Data. ACM Transactions on
Database Systems. 1(1): 9–36, 1976
– developed to facilitate database design by allowing
the specification of an enterprise schema
that represents the overall logical structure of a database
• Toolkit for mapping the meanings and interactions of real-world
enterprises onto a conceptual schema
• The ER data model employs three basic concepts:
– entity sets,
– relationship sets,
– attributes
• Associated diagrammatic representation (ER diagram)
– graphic expression of the overall logical structure of a database
3/9/22 Heiko Paulheim 9
Entity Sets
• An entity is an object that exists and is distinguishable from other
objects
– Example: Peter Chen, Mannheim, Star Wars
• An entity set is a set of entities of the same type that share the
same properties
– Example: set of all persons, cities, movies
• Each entity is represented by a set of attributes
– Example:
instructor = (ID, name, street, city, salary )
course= (course_id, title, credits)
• A subset of the attributes form a primary key of the entity set
i.e., uniquely identifying each member of the set
3/9/22 Heiko Paulheim 10
Entity Sets – Example
• instructor (instructor_id, instructor_name)
• student (student_id, student_name)
3/9/22 Heiko Paulheim 11
Relationship Sets
• A relationship is an association among several entities
Example:
44553 (Peltier) advisor 22222 (Einstein)
student entity relationship set instructor entity
• A relationship set is a mathematical relation among n  2 entities,
each taken from entity sets
{(e1, e2, … en) | e1  E1, e2  E2, …, en  En}
where (e1, e2, …, en) is a relationship
• Example:
(44553,22222)  advisor
3/9/22 Heiko Paulheim 12
Relationship Sets
3/9/22 Heiko Paulheim 13
Relationship Sets
• An attribute can also be associated with a relationship set
• E.g., advisor relationship set:
– date which captures the start of the supervision
3/9/22 Heiko Paulheim 14
Degree of a Relationship
• Definition: degree of a relationship
i.e., number of entity sets that are involved in relation set
• binary relationship (degree two)
– involve two entity sets
– the by far most frequent case
• Relationships between more than two entity sets (degree >2)
– e.g.: students work on projects under the guidance of an instructor
– relationship proj_guide is a ternary relationship
between instructor, student, and project
– those are rather rare
3/9/22 Heiko Paulheim 15
Cardinality Constraints
• 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:
– 1:1 (one to one)
– 1:n (one to many)
– n:1 (many to one)
– n:m (many to many)
3/9/22 Heiko Paulheim 16
Mapping Cardinalities – One to One
• One to one (1:1)
– Note: Some elements in A and B
may not be mapped to any
elements in the other set
• Examples
– student_works_on_thesis
– department_has_dean
3/9/22 Heiko Paulheim 17
Mapping Cardinalities – One to Many
• One to many (1:n)
– Note: Some elements in A and B
may not be mapped to any
elements in the other set
• Examples
– building_has_room
– course_taught_by_lecturer
3/9/22 Heiko Paulheim 18
Mapping Cardinalities – Many to One
• Many to one (n:1)
– Note: Some elements in A and B
may not be mapped to any
elements in the other set
• Examples
– room_located_in_building
– lecturer_teaches_course
• Note:
– the inverse of a 1:n relation is a n:1 relation
– and vice versa
3/9/22 Heiko Paulheim 19
Mapping Cardinalities – Many to Many
• Many to many (n:m)
– Note: Some elements in A and B
may not be mapped to any
elements in the other set
• Examples
– student_takes_course
– student_has_advisor
3/9/22 Heiko Paulheim 20
Distinguishing 1:n/n:1 and n:m Cardinalities
• Rule of thumb
– Always ask for the cardinality the other way around
• “A building may have multiple rooms...”
– “...but can a room be in multiple buildings?”
– No → building_has_room is 1:n
• “A department can be located in multiple buildings...”
– “...but can a building host multiple departments?”
– Yes → department_located_in_building is n:m
3/9/22 Heiko Paulheim 21
Relation Sets from the Same Entity Set
• The two entity sets in a relation set may be the same
• This holds independently from the cardinality!
• person_married_to_person
– 1:1
• person_is_father_of_person
– 1:n
• person_has_father
– n:1
• person_is_parent_of_person
– n:m
3/9/22 Heiko Paulheim 22
Attribute Types & Domains
• Attribute types:
– Simple and composite attributes
– Single-valued and multi-valued attributes
• Example: multi-valued attribute: phone_numbers
• Derived attributes
– Can be computed from other attributes
– Example: age (given date_of_birth)
• Domain – the set of permitted values for each attribute
3/9/22 Heiko Paulheim 23
Composite Attributes
3/9/22 Heiko Paulheim 24
Redundant Attributes
• Suppose we have entity sets:
– instructor, with attributes: ID, name, dept_name, salary
– department, with attributes: dept_name, building, budget
• In ERM, instructors and departments are connected by a relation
set
– e.g., instructor_belong_to_department (ID,dept_name)
• Now, dept_name is no longer needed in the instructor entity set
– It is redundant there
– Hence, we will remove it
• Note: sometimes, removed redundant attributes are reintroduced
when converting the conceptual model into a logical model
3/9/22 Heiko Paulheim 25
Weak Entity Sets
• Consider the set of buildings and rooms
– Entity set building(building_name,address)
– Entity set room(number,capacity)
– Relation set room_in_building (number,building_name)
• Note:
– As in the previous example, we have removed the redundant attribute
building_name from the entity set room
• Question:
– What is the primary key of the the entity set room?
3/9/22 Heiko Paulheim 26
Weak Entity Sets
• Weak entity sets are entity sets that
– do no not have a set of attributes sufficient
to identify each entity uniquely
– require an additional relation set to identify each entity uniquely
• Those relation sets are called identifying relation set
• Weak entities do not have primary keys
– A weak entity set has an identifying entity and a discriminator
– Example:
• building is the identifying entity
• number is the discriminator
• A weak entity cannot exist without the identifying entity
– e.g., a room cannot exist without the building
3/9/22 Heiko Paulheim 27
ER Diagrams
• Entity Relationship Diagrams (ER diagrams)
– are the graphical notation of entity relationship models
• Notation of entity sets:
– Rectangles represent entity sets
– Attributes listed inside entity rectangle
– Underlining indicates primary key attributes
3/9/22 Heiko Paulheim 28
ER Diagrams
• Diamonds represent relationship sets
3/9/22 Heiko Paulheim 29
ER Diagrams
• Diamonds represent relationship sets
– Attributes can be attached to relationship sets
3/9/22 Heiko Paulheim 30
Roles
• Entity sets of a relationship need not be distinct
– i.e., there may be a relationship set involving the same entity set twice
• Each occurrence of an entity set plays a “role” in the relationship
– The labels “course_id” and “prereq_id” are called roles
3/9/22 Heiko Paulheim 31
Cardinalities in ER Diagrams
• We express cardinality constraints by drawing either a directed line
(→), signifying “one”, or an undirected line (—), signifying “many”,
between the relationship set and the entity set.
• One-to-one relationship between an instructor and a student:
– A student is associated with at most one instructor via the relationship
advisor
– An instructor is associated with at most one student via the relationship
advisor
3/9/22 Heiko Paulheim 32
Cardinalities in ER Diagrams
• one-to-many relationship between an instructor and a student
– an instructor is associated with several (including 0) students via advisor
– a student is associated with at most one instructor via advisor
3/9/22 Heiko Paulheim 33
Cardinalities in ER Diagrams
• Many to many relationships
– An instructor is associated with several (possibly 0) students via advisor
– A student is associated with several (possibly 0) instructors via advisor
3/9/22 Heiko Paulheim 34
Total and Partial Participation
• Total participation (double line)
– every entity in the entity set participates in at least one relationship in
the relationship set
– i.e., every student must have an advisor
• recap: think of not null constraints
• Partial participation (single line)
– some entities may not particpate in the relationship
– e.g., not every instructor has to supervise a student
3/9/22 Heiko Paulheim 35
Complex Cardinality Constraints
• Notation for minimum/maximum cardinality of a relation
– Each student has exactly one advisor (i.e., min=max=1)
– Each instructor can be the advisor of multiple students,
but needs not be (i.e., min=0,max=∞)
• Notation:
– min..max
– * indicates no limit
3/9/22 Heiko Paulheim 36
Notation of Attribute Types
complex
attribute
multivalued
attrbiute
derived
attrbiute
3/9/22 Heiko Paulheim 37
Expressing Weak Entity Sets
• A weak entity set is depicted via a double rectangle
– The identifying relationship set is depicted by a double diamond
• The discriminator is underlined with a dashed line
– Primary key for section – (course_id, sec_id, semester, year)
building
name
address
located_in
room
number
capacity
why total
participation?
3/9/22 Heiko Paulheim 38
Higher Arity Relationship Sets
• Most relationship sets are binary
• Sometimes, ternary (or higher arity) relations occur
– ER models support that
• Example:
– Students work on projects under supervision of an instructor
3/9/22 Heiko Paulheim 39
Cardinality Constraints for Ternary Relations
• Only one single arrow (i.e., cardinality restriction) is allowed
for a ternary relation
– Example: each student can work in at most one project
under the supervision of some instructor(s)
why?
3/9/22 Heiko Paulheim 40
Cardinality Constraints for Ternary Relations
• Multiple single arrows (i.e., cardinality restrictions) would lead to
different possible interpretations
– Each student works on at most one project under at most one instructor
– For each project a student works on, there is at most one instructor
– For each instructor supervising a student, there is at most one project
• Hence, we do not allow for them
3/9/22 Heiko Paulheim 41
Specialization
• A concept very common in (object oriented) programming
– Entity sets are sub-/super sets of others
– They inherit all the attributes from their super sets
• Overlapping
– A person can be both an employee and a student
• Disjoint
– An employee can be either an instructor or a secretary
3/9/22 Heiko Paulheim 42
Partial vs. Total Specialization
• Partial specialization
– An employee may be an instructor or a secretary,
or an employee not further specified
– the default case
• Total specialization
– There are no other persons
than employees and students (in the DB)
– Needs to be specified in the diagram
– Analogy in OOP: abstract classes
total
3/9/22 Heiko Paulheim 43
A Full Example
3/9/22 Heiko Paulheim 44
Reduction to Relation Schemas
• How to get to from an ER model to a relational database model?
– Recap: relational database models consists of relations
• We have
– Entity sets and relationship sets
• Goal
– Translate entity and relationship sets uniformly to relation schemas
• Mechanism:
– For each entity set and relationship set there is a unique relation that is
assigned the name of the corresponding entity set or relationship set
– Each relation has a number of columns (generally corresponding to
attributes), which have unique names
3/9/22 Heiko Paulheim 45
Representing Entity Sets
• A strong entity set becomes a relation with the same attributes
building(name, address)
• A weak entity set becomes a relation that includes
– the column(s) of the primary key of the identifying strong entity set:
room (name, number, capacity)
• At the same time, name is a foreign key
– which integrity constraints should we use?
building
name
address
located_in
room
number
capacity
3/9/22 Heiko Paulheim 46
Representing Relationship Sets
• Many-to-many relationship sets
– represented as a relation with attributes for the primary keys of the two
participating entity sets
• Example: schema for relationship set advisor
advisor = (student_ID, instructor_ID)
3/9/22 Heiko Paulheim 47
Representing Relationship Sets
• Many-to-many relationship sets
– additional attributes of the relationship set become attributes
of the representing relation
• Example: schema for relationship set advisor
advisor = (student_ID, instructor_ID, date)
3/9/22 Heiko Paulheim 48
Representing Relationship Sets
• Special case for one-to-many relationship sets
– The primary key of the “many” side can become
a foreign key attribute on the “one” side
student = (ID, name, tot_cred, instructor_ID)
●
In case of partial participation, this may cause null values
3/9/22 Heiko Paulheim 49
Representing Relationship Sets
• Special case for one-to-one relationship sets
– The primary key on one side can be included on the other side
student = (ID, name, tot_cred, instructor_ID) or
instructor = (ID, name, salary, student_id)
●
In case of partial participation, this may cause null values
why not on
both sides?
3/9/22 Heiko Paulheim 50
Representing Attributes
• Composite attributes are flattened out by
creating a separate attribute for each
component attribute
• Add prefix of super attribute in case
ambiguous names occur
– e.g., street_number, phone_number
• Ignoring multivalued attributes, extended
instructor schema is
instructor(ID,
first_name, middle_initial, last_name,
street_number, street_name,
apt_number, city, state, zip_code,
date_of_birth)
3/9/22 Heiko Paulheim 51
Representing Multi-valued Attributes
• A multivalued attribute M of an entity E is represented by a separate
schema EM
• Schema EM has attributes corresponding to the primary key of E
and an attribute corresponding to multivalued attribute M
– Example: Multivalued attribute phone_number of instructor is
represented by a schema:
inst_phone= ( ID, phone_number)
• Each value of the multivalued attribute maps to a separate tuple of
the relation on schema EM
– Example: an instructor entity with primary key 22222 and phone
numbers 456-7890 and 123-4567 maps to two tuples:
(22222, 456-7890) and (22222, 123-4567)
3/9/22 Heiko Paulheim 52
Representing Derived Attributes
• Technically, we can create a view
create view instructor_age as
select ID,NOW()-date_of_birth as age
from instructor
3/9/22 Heiko Paulheim 53
Representing Higher Arity Relations
• Higher arity relationship sets are represented just like binary ones
– i.e., as one relation with the primary keys of the related entity sets
– proj_guide(instructor_ID, student_ID, project_ID)
3/9/22 Heiko Paulheim 54
Representing Specialization
• Method 1
– All three relations become relations
• primary key is shared
– Shared attributes are only represented
in the higher level entity
person(ID, name, street, city)
employee(ID, salary)
student(ID, tot_credits)
• Drawback:
– Accessing person information for employees and students requires
access to two relations
3/9/22 Heiko Paulheim 55
Representing Specialization
• Method 2
– All three relations become relations
• primary key is shared
– Shared attributes are only represented
in each entity
person(ID, name, street, city)
employee(ID, name, street, city, salary)
student(ID, name, street, city, tot_credits)
– Super relation can be omitted for total specialization
• Drawback:
– Redundant storage for overlapping specialization
• i.e., for persons that are both employees and students
3/9/22 Heiko Paulheim 56
Design Decisions in ER Modeling
• Entity sets vs. attributes
• Entity set
– Allows for additional information
– Supports multi-valued attributes
• in that case, the attribute would end as a relation
in the DB anyways
3/9/22 Heiko Paulheim 57
Entity Sets vs. Relationship Sets
• Students register for course sections
– This could be a simple relationship set as well
• Entity set can store additional information, e.g.
– Date of registration
3/9/22 Heiko Paulheim 58
Placement of Attributes for 1:1 Relationships
• The primary key on one side can be included on the other side
student = (ID, name, tot_cred, instructor_ID) or
instructor = (ID, name, salary, student_id)
●
Which one?
3/9/22 Heiko Paulheim 59
Binary vs. Non-Binary Relationships
• Sometimes, non-binary relationships can be replaced
by binary ones
person
name
birthday
has_parents
father
mother
child
3/9/22 Heiko Paulheim 60
Binary vs. Non-Binary Relationships
• Sometimes, non-binary relationships can be replaced
by binary ones
– This is usually the preferred solution
person
name
birthday
has_father
father
child
has_mother
mother
child
3/9/22 Heiko Paulheim 61
Binary vs. Non-Binary Relationships
• Sometimes, non-binary relationships can be replaced
by binary ones
– but sometimes, they are n-ary by nature
3/9/22 Heiko Paulheim 62
Binary vs. Non-Binary Relationships
• Sometimes, non-binary relationships can be replaced
by binary ones
– but sometimes, they are n-ary by nature
project
ID
name
student_
project
instructor
ID
name
salary
student
ID
name
tot_credits
instr_
project
instr_
student
?
3/9/22 Heiko Paulheim 63
Binary vs. Non-Binary Relationships
• Sometimes, non-binary relationships can be replaced
by binary ones
– but sometimes, they are n-ary by nature
• General decomposition schema:
project
ID
name
proj_
guide
instructor
ID
name
salary
student
ID
name
tot_credits
instr_
guide
guide stud_
guide
3/9/22 Heiko Paulheim 64
ER Design Decisions (Summary)
• The use of an attribute or entity set to represent an object
• Whether a real-world concept is best expressed by an entity set or a
relationship set
• The use of a ternary relationship versus a number of binary
relationships
• The use of a strong or weak entity set
• The use of specialization/generalization – contributes to modularity
in the design
3/9/22 Heiko Paulheim 65
Summary of ER Notation
3/9/22 Heiko Paulheim 66
Summary of ER Notation (ctd.)
3/9/22 Heiko Paulheim 67
Alternative ER Notations
3/9/22 Heiko Paulheim 68
Alternative ER Notations (ctd.)
3/9/22 Heiko Paulheim 69
Alternative Modeling Paradigms: UML
• Unified Modeling Language
– often used in software design
– similar scope: objects and their relations
– ISO standard since 2005
• ER models in RDBMS
– Direct translation to SQL
• UML models in software engineering
– Direct translation to source code
3/9/22 Heiko Paulheim 70
Alternative Modeling Paradigms: UML
!!!
3/9/22 Heiko Paulheim 71
Alternative Modeling Paradigms: UML
http://pld.cs.luc.edu/database/ER.html
3/9/22 Heiko Paulheim 72
Summary
• Designing databases
– i.e., how to get from your customer’s requirements…
– ...to a set of tables and attributes
• ER Models are an intermediate step
– Conceptual view on the database
– Graphical notation
– Can be used for discussion with customers
• Translation rules for ER to RDBMS
• Design decisions
– For ER Models (mostly business decisions)
– For translation to RDBMS (mostly computer science decisions)
3/9/22 Heiko Paulheim 73
Questions?

More Related Content

Similar to DBT04-ER-Models-v1.pdf

classes & objects introduction
classes & objects introductionclasses & objects introduction
classes & objects introductionKumar
 
Entity relationship modelling - DE L300
Entity relationship modelling - DE L300Entity relationship modelling - DE L300
Entity relationship modelling - DE L300Edwin Ayernor
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSRubal Sagwal
 
ER diagram slides for datanase stujdy-1.pdf
ER diagram slides for datanase stujdy-1.pdfER diagram slides for datanase stujdy-1.pdf
ER diagram slides for datanase stujdy-1.pdfSadiaSharmin40
 
Structural ModelingDr. Ardeshir BadrObjectives• .docx
Structural ModelingDr. Ardeshir BadrObjectives• .docxStructural ModelingDr. Ardeshir BadrObjectives• .docx
Structural ModelingDr. Ardeshir BadrObjectives• .docxsusanschei
 
Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Ganapathi M
 
New Quality Tools in total quality management
New Quality Tools in total quality managementNew Quality Tools in total quality management
New Quality Tools in total quality managementTamilselvan S
 
Chapter-3 Data Modeling using ER Model
Chapter-3 Data Modeling using ER ModelChapter-3 Data Modeling using ER Model
Chapter-3 Data Modeling using ER ModelKunal Anand
 
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdf
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdfunit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdf
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdfRojaPogul1
 
Chapter 6 Object Modeling .pptxInformation Technology Project Management
Chapter 6 Object Modeling .pptxInformation Technology Project ManagementChapter 6 Object Modeling .pptxInformation Technology Project Management
Chapter 6 Object Modeling .pptxInformation Technology Project ManagementAxmedMaxamuudYoonis
 
What_do_Knowledge_Graph_Embeddings_Learn.pdf
What_do_Knowledge_Graph_Embeddings_Learn.pdfWhat_do_Knowledge_Graph_Embeddings_Learn.pdf
What_do_Knowledge_Graph_Embeddings_Learn.pdfHeiko Paulheim
 
chapter06-120827115400-phpapp01.pdf
chapter06-120827115400-phpapp01.pdfchapter06-120827115400-phpapp01.pdf
chapter06-120827115400-phpapp01.pdfAxmedMaxamuud6
 
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptxDATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptxJasmineMichael1
 
Chapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdfChapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdfTamiratDejene1
 

Similar to DBT04-ER-Models-v1.pdf (20)

classes & objects introduction
classes & objects introductionclasses & objects introduction
classes & objects introduction
 
DBMS-Lec2.pptx
DBMS-Lec2.pptxDBMS-Lec2.pptx
DBMS-Lec2.pptx
 
Entity relationship modelling - DE L300
Entity relationship modelling - DE L300Entity relationship modelling - DE L300
Entity relationship modelling - DE L300
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMS
 
ER diagram slides for datanase stujdy-1.pdf
ER diagram slides for datanase stujdy-1.pdfER diagram slides for datanase stujdy-1.pdf
ER diagram slides for datanase stujdy-1.pdf
 
Dbs4
Dbs4Dbs4
Dbs4
 
Database part3-
Database part3-Database part3-
Database part3-
 
Database design
Database designDatabase design
Database design
 
Erd1
Erd1Erd1
Erd1
 
Structural ModelingDr. Ardeshir BadrObjectives• .docx
Structural ModelingDr. Ardeshir BadrObjectives• .docxStructural ModelingDr. Ardeshir BadrObjectives• .docx
Structural ModelingDr. Ardeshir BadrObjectives• .docx
 
Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0
 
New Quality Tools in total quality management
New Quality Tools in total quality managementNew Quality Tools in total quality management
New Quality Tools in total quality management
 
Chapter-3 Data Modeling using ER Model
Chapter-3 Data Modeling using ER ModelChapter-3 Data Modeling using ER Model
Chapter-3 Data Modeling using ER Model
 
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdf
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdfunit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdf
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdf
 
Revision ch 3
Revision ch 3Revision ch 3
Revision ch 3
 
Chapter 6 Object Modeling .pptxInformation Technology Project Management
Chapter 6 Object Modeling .pptxInformation Technology Project ManagementChapter 6 Object Modeling .pptxInformation Technology Project Management
Chapter 6 Object Modeling .pptxInformation Technology Project Management
 
What_do_Knowledge_Graph_Embeddings_Learn.pdf
What_do_Knowledge_Graph_Embeddings_Learn.pdfWhat_do_Knowledge_Graph_Embeddings_Learn.pdf
What_do_Knowledge_Graph_Embeddings_Learn.pdf
 
chapter06-120827115400-phpapp01.pdf
chapter06-120827115400-phpapp01.pdfchapter06-120827115400-phpapp01.pdf
chapter06-120827115400-phpapp01.pdf
 
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptxDATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
 
Chapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdfChapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdf
 

Recently uploaded

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Recently uploaded (20)

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 

DBT04-ER-Models-v1.pdf

  • 2. 3/9/22 Heiko Paulheim 2 Previously on Database Technology • Introduction to Relational Databases – A standard model for storing data – Using relations/tables • Introduction to SQL – Creating and changing tables – Reading and writing data into tables
  • 3. 3/9/22 Heiko Paulheim 3 Today • Designing databases – i.e., how to get from your customer’s requirements… – ...to a set of tables and attributes
  • 4. 3/9/22 Heiko Paulheim 4 Outline • Design Process • Modeling • Constraints • E-R Diagrams • Design Issues • Weak Entity Sets • Extended E-R Features • Reduction to Relation Schemas • Comparison UML
  • 5. 3/9/22 Heiko Paulheim 5 Database Design • Initial phase: requirements engineering – characterize fully the data needs of the prospective database users – which data needs to be stored? • ...and in which volumes? – which queries should be answered? • Conceptual schema – which types of entities and relations exist? – what attributes do they have?
  • 6. 3/9/22 Heiko Paulheim 6 Database Design • Final phase: from a conceptual to physical data model – Logical Design: find a “good” collection of relation schemas • Business decision – What attributes should we record in the database? • Computer Science decision – What relation schemas should we have and how should the attributes be distributed among the various relation schemas? – Physical Design – Deciding on the physical layout of the database
  • 7. 3/9/22 Heiko Paulheim 7 Database Design Approaches • Entity Relationship Model (today) – Models an enterprise as a collection of entities and relationships – Entity: a “thing” or “object” in the enterprise that is distinguishable from other objects • Described by a set of attributes – Relationship: an association among several entities – Represented diagrammatically by an entity-relationship diagram • Normalization Theory (next lecture) – Formalize what designs are bad, and test for them
  • 8. 3/9/22 Heiko Paulheim 8 Entity Relationship Model • Dates back to the 1970s – Chen, Peter Pin-Shan: The Entity–Relationship Model – Toward A Unified View of Data. ACM Transactions on Database Systems. 1(1): 9–36, 1976 – developed to facilitate database design by allowing the specification of an enterprise schema that represents the overall logical structure of a database • Toolkit for mapping the meanings and interactions of real-world enterprises onto a conceptual schema • The ER data model employs three basic concepts: – entity sets, – relationship sets, – attributes • Associated diagrammatic representation (ER diagram) – graphic expression of the overall logical structure of a database
  • 9. 3/9/22 Heiko Paulheim 9 Entity Sets • An entity is an object that exists and is distinguishable from other objects – Example: Peter Chen, Mannheim, Star Wars • An entity set is a set of entities of the same type that share the same properties – Example: set of all persons, cities, movies • Each entity is represented by a set of attributes – Example: instructor = (ID, name, street, city, salary ) course= (course_id, title, credits) • A subset of the attributes form a primary key of the entity set i.e., uniquely identifying each member of the set
  • 10. 3/9/22 Heiko Paulheim 10 Entity Sets – Example • instructor (instructor_id, instructor_name) • student (student_id, student_name)
  • 11. 3/9/22 Heiko Paulheim 11 Relationship Sets • A relationship is an association among several entities Example: 44553 (Peltier) advisor 22222 (Einstein) student entity relationship set instructor entity • A relationship set is a mathematical relation among n  2 entities, each taken from entity sets {(e1, e2, … en) | e1  E1, e2  E2, …, en  En} where (e1, e2, …, en) is a relationship • Example: (44553,22222)  advisor
  • 12. 3/9/22 Heiko Paulheim 12 Relationship Sets
  • 13. 3/9/22 Heiko Paulheim 13 Relationship Sets • An attribute can also be associated with a relationship set • E.g., advisor relationship set: – date which captures the start of the supervision
  • 14. 3/9/22 Heiko Paulheim 14 Degree of a Relationship • Definition: degree of a relationship i.e., number of entity sets that are involved in relation set • binary relationship (degree two) – involve two entity sets – the by far most frequent case • Relationships between more than two entity sets (degree >2) – e.g.: students work on projects under the guidance of an instructor – relationship proj_guide is a ternary relationship between instructor, student, and project – those are rather rare
  • 15. 3/9/22 Heiko Paulheim 15 Cardinality Constraints • 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: – 1:1 (one to one) – 1:n (one to many) – n:1 (many to one) – n:m (many to many)
  • 16. 3/9/22 Heiko Paulheim 16 Mapping Cardinalities – One to One • One to one (1:1) – Note: Some elements in A and B may not be mapped to any elements in the other set • Examples – student_works_on_thesis – department_has_dean
  • 17. 3/9/22 Heiko Paulheim 17 Mapping Cardinalities – One to Many • One to many (1:n) – Note: Some elements in A and B may not be mapped to any elements in the other set • Examples – building_has_room – course_taught_by_lecturer
  • 18. 3/9/22 Heiko Paulheim 18 Mapping Cardinalities – Many to One • Many to one (n:1) – Note: Some elements in A and B may not be mapped to any elements in the other set • Examples – room_located_in_building – lecturer_teaches_course • Note: – the inverse of a 1:n relation is a n:1 relation – and vice versa
  • 19. 3/9/22 Heiko Paulheim 19 Mapping Cardinalities – Many to Many • Many to many (n:m) – Note: Some elements in A and B may not be mapped to any elements in the other set • Examples – student_takes_course – student_has_advisor
  • 20. 3/9/22 Heiko Paulheim 20 Distinguishing 1:n/n:1 and n:m Cardinalities • Rule of thumb – Always ask for the cardinality the other way around • “A building may have multiple rooms...” – “...but can a room be in multiple buildings?” – No → building_has_room is 1:n • “A department can be located in multiple buildings...” – “...but can a building host multiple departments?” – Yes → department_located_in_building is n:m
  • 21. 3/9/22 Heiko Paulheim 21 Relation Sets from the Same Entity Set • The two entity sets in a relation set may be the same • This holds independently from the cardinality! • person_married_to_person – 1:1 • person_is_father_of_person – 1:n • person_has_father – n:1 • person_is_parent_of_person – n:m
  • 22. 3/9/22 Heiko Paulheim 22 Attribute Types & Domains • Attribute types: – Simple and composite attributes – Single-valued and multi-valued attributes • Example: multi-valued attribute: phone_numbers • Derived attributes – Can be computed from other attributes – Example: age (given date_of_birth) • Domain – the set of permitted values for each attribute
  • 23. 3/9/22 Heiko Paulheim 23 Composite Attributes
  • 24. 3/9/22 Heiko Paulheim 24 Redundant Attributes • Suppose we have entity sets: – instructor, with attributes: ID, name, dept_name, salary – department, with attributes: dept_name, building, budget • In ERM, instructors and departments are connected by a relation set – e.g., instructor_belong_to_department (ID,dept_name) • Now, dept_name is no longer needed in the instructor entity set – It is redundant there – Hence, we will remove it • Note: sometimes, removed redundant attributes are reintroduced when converting the conceptual model into a logical model
  • 25. 3/9/22 Heiko Paulheim 25 Weak Entity Sets • Consider the set of buildings and rooms – Entity set building(building_name,address) – Entity set room(number,capacity) – Relation set room_in_building (number,building_name) • Note: – As in the previous example, we have removed the redundant attribute building_name from the entity set room • Question: – What is the primary key of the the entity set room?
  • 26. 3/9/22 Heiko Paulheim 26 Weak Entity Sets • Weak entity sets are entity sets that – do no not have a set of attributes sufficient to identify each entity uniquely – require an additional relation set to identify each entity uniquely • Those relation sets are called identifying relation set • Weak entities do not have primary keys – A weak entity set has an identifying entity and a discriminator – Example: • building is the identifying entity • number is the discriminator • A weak entity cannot exist without the identifying entity – e.g., a room cannot exist without the building
  • 27. 3/9/22 Heiko Paulheim 27 ER Diagrams • Entity Relationship Diagrams (ER diagrams) – are the graphical notation of entity relationship models • Notation of entity sets: – Rectangles represent entity sets – Attributes listed inside entity rectangle – Underlining indicates primary key attributes
  • 28. 3/9/22 Heiko Paulheim 28 ER Diagrams • Diamonds represent relationship sets
  • 29. 3/9/22 Heiko Paulheim 29 ER Diagrams • Diamonds represent relationship sets – Attributes can be attached to relationship sets
  • 30. 3/9/22 Heiko Paulheim 30 Roles • Entity sets of a relationship need not be distinct – i.e., there may be a relationship set involving the same entity set twice • Each occurrence of an entity set plays a “role” in the relationship – The labels “course_id” and “prereq_id” are called roles
  • 31. 3/9/22 Heiko Paulheim 31 Cardinalities in ER Diagrams • We express cardinality constraints by drawing either a directed line (→), signifying “one”, or an undirected line (—), signifying “many”, between the relationship set and the entity set. • One-to-one relationship between an instructor and a student: – A student is associated with at most one instructor via the relationship advisor – An instructor is associated with at most one student via the relationship advisor
  • 32. 3/9/22 Heiko Paulheim 32 Cardinalities in ER Diagrams • one-to-many relationship between an instructor and a student – an instructor is associated with several (including 0) students via advisor – a student is associated with at most one instructor via advisor
  • 33. 3/9/22 Heiko Paulheim 33 Cardinalities in ER Diagrams • Many to many relationships – An instructor is associated with several (possibly 0) students via advisor – A student is associated with several (possibly 0) instructors via advisor
  • 34. 3/9/22 Heiko Paulheim 34 Total and Partial Participation • Total participation (double line) – every entity in the entity set participates in at least one relationship in the relationship set – i.e., every student must have an advisor • recap: think of not null constraints • Partial participation (single line) – some entities may not particpate in the relationship – e.g., not every instructor has to supervise a student
  • 35. 3/9/22 Heiko Paulheim 35 Complex Cardinality Constraints • Notation for minimum/maximum cardinality of a relation – Each student has exactly one advisor (i.e., min=max=1) – Each instructor can be the advisor of multiple students, but needs not be (i.e., min=0,max=∞) • Notation: – min..max – * indicates no limit
  • 36. 3/9/22 Heiko Paulheim 36 Notation of Attribute Types complex attribute multivalued attrbiute derived attrbiute
  • 37. 3/9/22 Heiko Paulheim 37 Expressing Weak Entity Sets • A weak entity set is depicted via a double rectangle – The identifying relationship set is depicted by a double diamond • The discriminator is underlined with a dashed line – Primary key for section – (course_id, sec_id, semester, year) building name address located_in room number capacity why total participation?
  • 38. 3/9/22 Heiko Paulheim 38 Higher Arity Relationship Sets • Most relationship sets are binary • Sometimes, ternary (or higher arity) relations occur – ER models support that • Example: – Students work on projects under supervision of an instructor
  • 39. 3/9/22 Heiko Paulheim 39 Cardinality Constraints for Ternary Relations • Only one single arrow (i.e., cardinality restriction) is allowed for a ternary relation – Example: each student can work in at most one project under the supervision of some instructor(s) why?
  • 40. 3/9/22 Heiko Paulheim 40 Cardinality Constraints for Ternary Relations • Multiple single arrows (i.e., cardinality restrictions) would lead to different possible interpretations – Each student works on at most one project under at most one instructor – For each project a student works on, there is at most one instructor – For each instructor supervising a student, there is at most one project • Hence, we do not allow for them
  • 41. 3/9/22 Heiko Paulheim 41 Specialization • A concept very common in (object oriented) programming – Entity sets are sub-/super sets of others – They inherit all the attributes from their super sets • Overlapping – A person can be both an employee and a student • Disjoint – An employee can be either an instructor or a secretary
  • 42. 3/9/22 Heiko Paulheim 42 Partial vs. Total Specialization • Partial specialization – An employee may be an instructor or a secretary, or an employee not further specified – the default case • Total specialization – There are no other persons than employees and students (in the DB) – Needs to be specified in the diagram – Analogy in OOP: abstract classes total
  • 43. 3/9/22 Heiko Paulheim 43 A Full Example
  • 44. 3/9/22 Heiko Paulheim 44 Reduction to Relation Schemas • How to get to from an ER model to a relational database model? – Recap: relational database models consists of relations • We have – Entity sets and relationship sets • Goal – Translate entity and relationship sets uniformly to relation schemas • Mechanism: – For each entity set and relationship set there is a unique relation that is assigned the name of the corresponding entity set or relationship set – Each relation has a number of columns (generally corresponding to attributes), which have unique names
  • 45. 3/9/22 Heiko Paulheim 45 Representing Entity Sets • A strong entity set becomes a relation with the same attributes building(name, address) • A weak entity set becomes a relation that includes – the column(s) of the primary key of the identifying strong entity set: room (name, number, capacity) • At the same time, name is a foreign key – which integrity constraints should we use? building name address located_in room number capacity
  • 46. 3/9/22 Heiko Paulheim 46 Representing Relationship Sets • Many-to-many relationship sets – represented as a relation with attributes for the primary keys of the two participating entity sets • Example: schema for relationship set advisor advisor = (student_ID, instructor_ID)
  • 47. 3/9/22 Heiko Paulheim 47 Representing Relationship Sets • Many-to-many relationship sets – additional attributes of the relationship set become attributes of the representing relation • Example: schema for relationship set advisor advisor = (student_ID, instructor_ID, date)
  • 48. 3/9/22 Heiko Paulheim 48 Representing Relationship Sets • Special case for one-to-many relationship sets – The primary key of the “many” side can become a foreign key attribute on the “one” side student = (ID, name, tot_cred, instructor_ID) ● In case of partial participation, this may cause null values
  • 49. 3/9/22 Heiko Paulheim 49 Representing Relationship Sets • Special case for one-to-one relationship sets – The primary key on one side can be included on the other side student = (ID, name, tot_cred, instructor_ID) or instructor = (ID, name, salary, student_id) ● In case of partial participation, this may cause null values why not on both sides?
  • 50. 3/9/22 Heiko Paulheim 50 Representing Attributes • Composite attributes are flattened out by creating a separate attribute for each component attribute • Add prefix of super attribute in case ambiguous names occur – e.g., street_number, phone_number • Ignoring multivalued attributes, extended instructor schema is instructor(ID, first_name, middle_initial, last_name, street_number, street_name, apt_number, city, state, zip_code, date_of_birth)
  • 51. 3/9/22 Heiko Paulheim 51 Representing Multi-valued Attributes • A multivalued attribute M of an entity E is represented by a separate schema EM • Schema EM has attributes corresponding to the primary key of E and an attribute corresponding to multivalued attribute M – Example: Multivalued attribute phone_number of instructor is represented by a schema: inst_phone= ( ID, phone_number) • Each value of the multivalued attribute maps to a separate tuple of the relation on schema EM – Example: an instructor entity with primary key 22222 and phone numbers 456-7890 and 123-4567 maps to two tuples: (22222, 456-7890) and (22222, 123-4567)
  • 52. 3/9/22 Heiko Paulheim 52 Representing Derived Attributes • Technically, we can create a view create view instructor_age as select ID,NOW()-date_of_birth as age from instructor
  • 53. 3/9/22 Heiko Paulheim 53 Representing Higher Arity Relations • Higher arity relationship sets are represented just like binary ones – i.e., as one relation with the primary keys of the related entity sets – proj_guide(instructor_ID, student_ID, project_ID)
  • 54. 3/9/22 Heiko Paulheim 54 Representing Specialization • Method 1 – All three relations become relations • primary key is shared – Shared attributes are only represented in the higher level entity person(ID, name, street, city) employee(ID, salary) student(ID, tot_credits) • Drawback: – Accessing person information for employees and students requires access to two relations
  • 55. 3/9/22 Heiko Paulheim 55 Representing Specialization • Method 2 – All three relations become relations • primary key is shared – Shared attributes are only represented in each entity person(ID, name, street, city) employee(ID, name, street, city, salary) student(ID, name, street, city, tot_credits) – Super relation can be omitted for total specialization • Drawback: – Redundant storage for overlapping specialization • i.e., for persons that are both employees and students
  • 56. 3/9/22 Heiko Paulheim 56 Design Decisions in ER Modeling • Entity sets vs. attributes • Entity set – Allows for additional information – Supports multi-valued attributes • in that case, the attribute would end as a relation in the DB anyways
  • 57. 3/9/22 Heiko Paulheim 57 Entity Sets vs. Relationship Sets • Students register for course sections – This could be a simple relationship set as well • Entity set can store additional information, e.g. – Date of registration
  • 58. 3/9/22 Heiko Paulheim 58 Placement of Attributes for 1:1 Relationships • The primary key on one side can be included on the other side student = (ID, name, tot_cred, instructor_ID) or instructor = (ID, name, salary, student_id) ● Which one?
  • 59. 3/9/22 Heiko Paulheim 59 Binary vs. Non-Binary Relationships • Sometimes, non-binary relationships can be replaced by binary ones person name birthday has_parents father mother child
  • 60. 3/9/22 Heiko Paulheim 60 Binary vs. Non-Binary Relationships • Sometimes, non-binary relationships can be replaced by binary ones – This is usually the preferred solution person name birthday has_father father child has_mother mother child
  • 61. 3/9/22 Heiko Paulheim 61 Binary vs. Non-Binary Relationships • Sometimes, non-binary relationships can be replaced by binary ones – but sometimes, they are n-ary by nature
  • 62. 3/9/22 Heiko Paulheim 62 Binary vs. Non-Binary Relationships • Sometimes, non-binary relationships can be replaced by binary ones – but sometimes, they are n-ary by nature project ID name student_ project instructor ID name salary student ID name tot_credits instr_ project instr_ student ?
  • 63. 3/9/22 Heiko Paulheim 63 Binary vs. Non-Binary Relationships • Sometimes, non-binary relationships can be replaced by binary ones – but sometimes, they are n-ary by nature • General decomposition schema: project ID name proj_ guide instructor ID name salary student ID name tot_credits instr_ guide guide stud_ guide
  • 64. 3/9/22 Heiko Paulheim 64 ER Design Decisions (Summary) • The use of an attribute or entity set to represent an object • Whether a real-world concept is best expressed by an entity set or a relationship set • The use of a ternary relationship versus a number of binary relationships • The use of a strong or weak entity set • The use of specialization/generalization – contributes to modularity in the design
  • 65. 3/9/22 Heiko Paulheim 65 Summary of ER Notation
  • 66. 3/9/22 Heiko Paulheim 66 Summary of ER Notation (ctd.)
  • 67. 3/9/22 Heiko Paulheim 67 Alternative ER Notations
  • 68. 3/9/22 Heiko Paulheim 68 Alternative ER Notations (ctd.)
  • 69. 3/9/22 Heiko Paulheim 69 Alternative Modeling Paradigms: UML • Unified Modeling Language – often used in software design – similar scope: objects and their relations – ISO standard since 2005 • ER models in RDBMS – Direct translation to SQL • UML models in software engineering – Direct translation to source code
  • 70. 3/9/22 Heiko Paulheim 70 Alternative Modeling Paradigms: UML !!!
  • 71. 3/9/22 Heiko Paulheim 71 Alternative Modeling Paradigms: UML http://pld.cs.luc.edu/database/ER.html
  • 72. 3/9/22 Heiko Paulheim 72 Summary • Designing databases – i.e., how to get from your customer’s requirements… – ...to a set of tables and attributes • ER Models are an intermediate step – Conceptual view on the database – Graphical notation – Can be used for discussion with customers • Translation rules for ER to RDBMS • Design decisions – For ER Models (mostly business decisions) – For translation to RDBMS (mostly computer science decisions)
  • 73. 3/9/22 Heiko Paulheim 73 Questions?