Database Design the Entity Relationship Approach
Transcript of Database Design the Entity Relationship Approach
-
8/8/2019 Database Design the Entity Relationship Approach
1/102
Database System Concepts, 6th Ed.
Silberschatz, Korth and SudarshanSee www.db-book.com for conditions on re-use
Chapter 7: EntityChapter 7: Entity--Relationship ModelRelationship Model
-
8/8/2019 Database Design the Entity Relationship Approach
2/102
Silberschatz, Korth and Sudarshan7.2Database System Concepts - 6th Edition
Chapter 7: EntityChapter 7: Entity--Relationship ModelRelationship Model
Design Process
Modeling
Constraints
E-R Diagram
Design Issues
Weak Entity Sets
Extended E-R Features
Design of the Bank Database
Reduction to Relation Schemas
Database Design
UML
-
8/8/2019 Database Design the Entity Relationship Approach
3/102
Silberschatz, Korth and Sudarshan7.3Database System Concepts - 6th Edition
ModelingModeling
A databasecan be modeled as:
a collection of entities,
relationship among entities.
An entity is an object that exists and is distinguishable from otherobjects.
Example: specific person, company, event, plant
Entities have attributes
Example: people have namesand addresses
An entity set is a set of entities of the same type that share the sameproperties.
Example: set of all persons, companies, trees, holidays
-
8/8/2019 Database Design the Entity Relationship Approach
4/102
Silberschatz, Korth and Sudarshan7.4Database System Concepts - 6th Edition
Entity SetsEntity Sets instructorinstructorandand studentstudent
instructor_ID instructor_name student-ID student_name
-
8/8/2019 Database Design the Entity Relationship Approach
5/102
Silberschatz, Korth and Sudarshan7.5Database System Concepts - 6th Edition
Relationship SetsRelationship Sets
A relationship is an association among several entities
Example:44553 (Peltier) advisor 22222 (Einstein)
studententity relationship set instructorentity
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
-
8/8/2019 Database Design the Entity Relationship Approach
6/102
-
8/8/2019 Database Design the Entity Relationship Approach
7/102Silberschatz, Korth and Sudarshan7.7Database System Concepts - 6th Edition
Relationship Sets (Cont.)Relationship Sets (Cont.)
An attribute can also be property of a relationship set.
For instance, the advisorrelationship set between entity setsinstructorand studentmay have the attribute datewhich tracks whenthe student started being associated with the advisor
-
8/8/2019 Database Design the Entity Relationship Approach
8/102Silberschatz, Korth and Sudarshan7.8Database System Concepts - 6th Edition
Degree of a Relationship SetDegree of a Relationship Set
binary relationship
involve two entity sets (or degree two).
most relationship sets in a database system are binary.
Relationships between more than two entity sets are rare. Mostrelationships are binary. (More on this later.)
Example: studentswork on research projectsunder theguidance of an instructor.
relationship proj_guideis a ternary relationship betweeninstructor, student, and project
-
8/8/2019 Database Design the Entity Relationship Approach
9/102Silberschatz, Korth and Sudarshan7.9Database System Concepts - 6th Edition
AttributesAttributes
An entity is represented by a set of attributes, that is descriptiveproperties possessed by all members of an entity set.
Example:
instructor =(ID, name, street, city, salary)course=(course_id, title, credits)
Domain the set of permitted values for each attribute
Attribute types:
Simple and composite attributes.
Single-valued and multivalued attributes
Example: multivalued attribute: phone_numbers
Derived attributes
Can be computed from other attributes
Example: age, given date_of_birth
-
8/8/2019 Database Design the Entity Relationship Approach
10/102Silberschatz, Korth and Sudarshan7.10Database System Concepts - 6th Edition
Composite AttributesComposite Attributes
-
8/8/2019 Database Design the Entity Relationship Approach
11/102Silberschatz, Korth and Sudarshan7.11Database System Concepts - 6th Edition
Mapping Cardinality ConstraintsMapping Cardinality Constraints
Express the number of entities to which another entity can beassociated via a relationship set.
Most useful in describing binary relationship sets.
For a binary relationship set the mapping cardinality must be one ofthe following types:
One to one
One to many
Many to one
Many to many
-
8/8/2019 Database Design the Entity Relationship Approach
12/102Silberschatz, Korth and Sudarshan7.12Database System Concepts - 6th Edition
Mapping CardinalitiesMapping Cardinalities
One to one One to many
Note: Some elements in A and Bmay not be mapped to any
elements in the other set
-
8/8/2019 Database Design the Entity Relationship Approach
13/102Silberschatz, Korth and Sudarshan7.13Database System Concepts - 6th Edition
Mapping CardinalitiesMapping Cardinalities
Many toone
Many to many
Note: Some elements in A and B may not be mapped to any
elements in the other set
-
8/8/2019 Database Design the Entity Relationship Approach
14/102Silberschatz, Korth and Sudarshan7.14Database System Concepts - 6th Edition
KeysKeys
A super key of an entity set is a set of one or more attributeswhose values uniquely determine each entity.
A candidate key of an entity set is a minimal super key
IDis candidate key of instructor
course_idis candidate key of course
Although several candidate keys may exist, one of the candidatekeys is selected to be the primary key.
-
8/8/2019 Database Design the Entity Relationship Approach
15/102Silberschatz, Korth and Sudarshan7.15Database System Concepts - 6th Edition
Keys for Relationship SetsKeys for Relationship Sets
The combination of primary keys of the participating entity setsforms a super key of a relationship set.
(s_id, i_id) is the super key of advisor
NOTE: this meansa pair of entity sets can have at most onerelationship in a particular relationship set.
Example: if we wish to track multiple meeting dates betweena student and her advisor, we cannot assume a relationship
for each meeting. We can use a multivalued attributethough
Must consider the mapping cardinality of the relationship set whendeciding what are the candidate keys
Need to consider semantics of relationship set in selecting theprimary key in case of more than one candidate key
-
8/8/2019 Database Design the Entity Relationship Approach
16/102Silberschatz, Korth and Sudarshan7.16Database System Concepts - 6th Edition
Redundant AttributesRedundant Attributes
Suppose we have entity sets
instructor, with attributes including dept_name
department
and a relationship
inst_deptrelating instructorand department
Attribute dept_namein entity instructoris redundant since there is anexplicit relationship inst_deptwhich relates instructors to departments
The attribute replicates information present in the relationship, andshould be removed from instructor
BUT: when converting back to tables, in some cases the attributegets reintroduced, as we will see.
-
8/8/2019 Database Design the Entity Relationship Approach
17/102Silberschatz, Korth and Sudarshan7.17Database System Concepts - 6th Edition
EE--R DiagramsR Diagrams
Rectangles represent entity sets.
Diamonds represent relationship sets.
Attributes listed inside entity rectangle
Underline indicates primary key attributes
-
8/8/2019 Database Design the Entity Relationship Approach
18/102Silberschatz, Korth and Sudarshan7.18Database System Concepts - 6th Edition
Entity With Composite,Entity With Composite, MultivaluedMultivalued, and Derived, and Derived
AttributesAttributes
-
8/8/2019 Database Design the Entity Relationship Approach
19/102Silberschatz, Korth and Sudarshan7.19Database System Concepts - 6th Edition
Relationship Sets with AttributesRelationship Sets with Attributes
-
8/8/2019 Database Design the Entity Relationship Approach
20/102Silberschatz, Korth and Sudarshan7.20Database System Concepts - 6th Edition
RolesRoles
Entity sets of a relationship need not be distinct
Each occurrence of an entity set plays a role in the relationship
The labels course_id and prereq_id are called roles.
-
8/8/2019 Database Design the Entity Relationship Approach
21/102Silberschatz, Korth and Sudarshan7.21Database System Concepts - 6th Edition
Cardinality ConstraintsCardinality Constraints
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:
A student is associated with at most one instructorvia therelationship advisor
A studentis associated with at most one departmentviastud_dept
-
8/8/2019 Database Design the Entity Relationship Approach
22/102Silberschatz, Korth and Sudarshan7.22Database System Concepts - 6th Edition
OneOne--toto--One RelationshipOne Relationship
one-to-one relationship between an instructorand a student
an instructor is associated with at most one student via advisor
and a student is associated with at most one instructor via
advisor
-
8/8/2019 Database Design the Entity Relationship Approach
23/102Silberschatz, Korth and Sudarshan7.23Database System Concepts - 6th Edition
OneOne--toto--Many RelationshipMany Relationship
one-to-many relationship between an instructorand a student
an instructor is associated with several (including 0) students
via advisor
a student is associated with at most one instructor via advisor,
-
8/8/2019 Database Design the Entity Relationship Approach
24/102
Silberschatz, Korth and Sudarshan7.24Database System Concepts - 6th Edition
ManyMany--toto--One RelationshipsOne Relationships
In a many-to-one relationship between an instructorand a student,
an instructor is associated with at most one student viaadvisor,
and a student is associated with several (including 0)instructors via advisor
-
8/8/2019 Database Design the Entity Relationship Approach
25/102
Silberschatz, Korth and Sudarshan7.25Database System Concepts - 6th Edition
ManyMany--toto--Many RelationshipMany Relationship
An instructor is associated with several (possibly 0) students viaadvisor
A student is associated with several (possibly 0) instructors viaadvisor
P ti i ti f E tit S t iP ti i ti f E tit S t i
-
8/8/2019 Database Design the Entity Relationship Approach
26/102
Silberschatz, Korth and Sudarshan7.26Database System Concepts - 6th Edition
Participation of an Entity Set in aParticipation of an Entity Set in a
Relationship SetRelationship Set
Total participation (indicated by double line): every entity in theentity set participates in at least one relationship in the relationshipset
E.g., participation of section in sec_courseis total every sectionmust have an associated course
Partial participation: some entities may not participate in anyrelationship in the relationship set
Example: participation of instructorin advisoris partial
-
8/8/2019 Database Design the Entity Relationship Approach
27/102
Silberschatz, Korth and Sudarshan7.27Database System Concepts - 6th Edition
Alternative Notation for Cardinality LimitsAlternative Notation for Cardinality Limits
Cardinality limits can also express participation constraints
-
8/8/2019 Database Design the Entity Relationship Approach
28/102
Silberschatz, Korth and Sudarshan7.28Database System Concepts - 6th Edition
EE--RR Diagram with a Ternary RelationshipDiagram with a Ternary Relationship
C di lit C t i t TCardinality Constraints on Ternary
-
8/8/2019 Database Design the Entity Relationship Approach
29/102
Silberschatz, Korth and Sudarshan7.29Database System Concepts - 6th Edition
Cardinality Constraints on TernaryCardinality Constraints on Ternary
RelationshipRelationship
We allow at most one arrow out of a ternary (or greater degree)relationship to indicate a cardinality constraint
E.g., an arrow from proj_guideto instructorindicates each student has
at most one guide for a project
If there is more than one arrow, there are two ways of defining themeaning.
E.g., a ternary relationship Rbetween A, Band Cwith arrows to B
and Ccould mean1. each A entity is associated with a unique entity from Band Cor
2. each pair of entities from (A, B) is associated with a unique Centity, and each pair (A, C) is associated with a unique B
Each alternative has been used in different formalisms
To avoid confusion we outlaw more than one arrow
-
8/8/2019 Database Design the Entity Relationship Approach
30/102
Database System Concepts, 6th Ed.
Silberschatz, Korth and SudarshanSee www.db-book.com for conditions on re-use
How about doing an ER designHow about doing an ER design
interactively on the board?interactively on the board?
Suggest an application to be modeled.Suggest an application to be modeled.
-
8/8/2019 Database Design the Entity Relationship Approach
31/102
Silberschatz, Korth and Sudarshan7.31Database System Concepts - 6th Edition
Weak Entity SetsWeak Entity Sets
An entity set that does not have a primary key is referred to as aweak entity set.
The existence of a weak entity set depends on the existence of a
identifying entity set
It must relate to the identifying entity set via a total, one-to-manyrelationship set from the identifying to the weak entity set
Identifying relationship depicted using a double diamond
The discriminator (or partial key) of a weak entity set is the set ofattributes that distinguishes among all the entities of a weak entityset.
The primary key of a weak entity set is formed by the primary key of
the strong entity set on which the weak entity set is existencedependent, plus the weak entity sets discriminator.
-
8/8/2019 Database Design the Entity Relationship Approach
32/102
-
8/8/2019 Database Design the Entity Relationship Approach
33/102
Silberschatz, Korth and Sudarshan7.33Database System Concepts - 6th Edition
Weak Entity Sets (Cont.)Weak Entity Sets (Cont.)
Note: the primary key of the strong entity set is not explicitly storedwith the weak entity set, since it is implicit in the identifyingrelationship.
If course_idwere explicitly stored, sectioncould be made a strong
entity, but then the relationship between sectionand coursewouldbe duplicated by an implicit relationship defined by the attributecourse_idcommon to courseand section
D
-
8/8/2019 Database Design the Entity Relationship Approach
34/102
Silberschatz, Korth and Sudarshan7.34Database System Concepts - 6th Edition
EE--R Diagram for a University EnterpriseR Diagram for a University Enterprise
-
8/8/2019 Database Design the Entity Relationship Approach
35/102
Silberschatz, Korth and Sudarshan7.35Database System Concepts - 6th Edition
Reduction to Relational Schemas
S
-
8/8/2019 Database Design the Entity Relationship Approach
36/102
Silberschatz, Korth and Sudarshan7.36Database System Concepts - 6th Edition
Reduction to Relation SchemasReduction to Relation Schemas
Entity sets and relationship sets can be expressed uniformly asrelation schemasthat represent the contents of the database.
A database which conforms to an E-R diagram can be represented bya collection of schemas.
For each entity set and relationship set there is a unique schema thatis assigned the name of the corresponding entity set or relationshipset.
Each schema has a number of columns (generally corresponding toattributes), which have unique names.
-
8/8/2019 Database Design the Entity Relationship Approach
37/102
-
8/8/2019 Database Design the Entity Relationship Approach
38/102
R d d f S hR d d f S h
-
8/8/2019 Database Design the Entity Relationship Approach
39/102
Silberschatz, Korth and Sudarshan7.39Database System Concepts - 6th Edition
Redundancy of SchemasRedundancy of Schemas
Many-to-one and one-to-many relationship sets that are total on themany-side can be represented by adding an extra attribute to themany side, containing the primary key of the one side
Example: Instead of creating a schema for relationship set inst_dept,add an attribute dept_nameto the schema arising from entity setinstructor
-
8/8/2019 Database Design the Entity Relationship Approach
40/102
C it dComposite and M lti l dMultivalued Att ib tAttributes
-
8/8/2019 Database Design the Entity Relationship Approach
41/102
Silberschatz, Korth and Sudarshan7.41Database System Concepts - 6th Edition
Composite andComposite and MultivaluedMultivalued AttributesAttributes
Composite attributes are flattened out by creating aseparate attribute for each component attribute
Example: given entity set instructorwithcomposite attribute namewith component
attributes first_nameand last_namethe schemacorresponding to the entity set has two attributesname_first_name and name_last_name
Prefix omitted if there is no ambiguity
Ignoring multivalued attributes, extended instructorschema is
instructor(ID,
first_name, middle_initial, last_name,street_number, street_name,
apt_number, city, state, zip_code,date_of_birth)
Composite andComposite and MultivaluedMultivalued AttributesAttributes
-
8/8/2019 Database Design the Entity Relationship Approach
42/102
Silberschatz, Korth and Sudarshan7.42Database System Concepts - 6th Edition
Composite andComposite and MultivaluedMultivalued AttributesAttributes
A multivalued attribute Mof an entity Eis represented by a separateschema EM
Schema EMhas attributes corresponding to the primary key of Eand an attribute corresponding to multivalued attribute M
Example: Multivalued attribute phone_numberof instructorisrepresented by a schema:
inst_phone=( ID, phone_number)
Each value of the multivalued attribute maps to a separate tuple ofthe relation on schema EM
For example, an instructorentity with primary key 22222 andphone numbers 456-7890 and 123-4567 maps to two tuples:
(22222, 456-7890) and (22222, 123-4567)
M lti l dM lti l d Att ib t (C t )Att ib t (C t )
-
8/8/2019 Database Design the Entity Relationship Approach
43/102
Silberschatz, Korth and Sudarshan7.43Database System Concepts - 6th Edition
MultivaluedMultivalued Attributes (Cont.)Attributes (Cont.)
Special case:entity time_slot has only one attribute other than theprimary-key attribute, and that attribute is multivalued
Optimization: Dont create the relation corresponding to the entity,just create the one corresponding to the multivalued attribute
time_slot(time_slot_id, day, start_time, end_time)
Caveat: time_slotattribute of section (from sec_time_slot) cannot bea foreign key due to this optimization
D i ID i I
-
8/8/2019 Database Design the Entity Relationship Approach
44/102
Silberschatz, Korth and Sudarshan7.44Database System Concepts - 6th Edition
Design IssuesDesign Issues
Use of entity sets vs. attributes
Use of phone as an entity allows extra information about phone numbers(plus multiple phone numbers)
D i ID i I
-
8/8/2019 Database Design the Entity Relationship Approach
45/102
Silberschatz, Korth and Sudarshan7.45Database System Concepts - 6th Edition
Design IssuesDesign Issues
Use of entity sets vs. relationship setsPossible guideline is to designate a relationship set to describe an actionthat occurs between entities
D i IDesign Issues
-
8/8/2019 Database Design the Entity Relationship Approach
46/102
Silberschatz, Korth and Sudarshan7.46Database System Concepts - 6th Edition
Design IssuesDesign Issues
Binary versus n-ary relationship setsAlthough it is possible to replace any nonbinary (n-ary, for n> 2)relationship set by a number of distinct binary relationship sets, a n-aryrelationship set shows more clearly that several entities participate in a
single relationship.
Placement of relationship attributes
e.g., attribute dateas attribute of advisoror as attribute of student
Binary Vs NonBinary Vs Non Binary RelationshipsBinary Relationships
-
8/8/2019 Database Design the Entity Relationship Approach
47/102
Silberschatz, Korth and Sudarshan7.47Database System Concepts - 6th Edition
Binary Vs. NonBinary Vs. Non--Binary RelationshipsBinary Relationships
Some relationships that appear to be non-binary may be betterrepresented using binary relationships
E.g., A ternary relationship parents, relating a child to his/herfather and mother, is best replaced by two binary relationships,fatherand mother
Using two binary relationships allows partial information (e.g.,only mother being know)
But there are some relationships that are naturally non-binary Example: proj_guide
C ti NC ti N Bi R l ti hi t Bi FBi R l ti hi t Bi F
-
8/8/2019 Database Design the Entity Relationship Approach
48/102
Silberschatz, Korth and Sudarshan7.48Database System Concepts - 6th Edition
Converting NonConverting Non--Binary Relationships to Binary FormBinary Relationships to Binary Form
In general, any non-binary relationship can be represented usingbinary relationships by creating an artificial entity set.
Replace Rbetween entity sets A, B and C by an entity set E, andthree relationship sets:
1. RA, relating Eand A 2. RB, relating Eand B3. RC, relating Eand C
Create a special identifying attribute for E
Add any attributes of Rto E
For each relationship (ai , bi , ci) in R, create1. a new entity ei in the entity set E 2. add (ei , ai) to RA
3. add (ei , bi) to RB 4. add (ei , ci) to RC
-
8/8/2019 Database Design the Entity Relationship Approach
49/102
-
8/8/2019 Database Design the Entity Relationship Approach
50/102
Silberschatz, Korth and Sudarshan7.50Database System Concepts - 6th Edition
Extended ER Features
Extended EExtended E R Features: SpecializationR Features: Specialization
-
8/8/2019 Database Design the Entity Relationship Approach
51/102
Silberschatz, Korth and Sudarshan7.51Database System Concepts - 6th Edition
Extended EExtended E--R Features: SpecializationR Features: Specialization
Top-down design process; we designate subgroupings within an entity setthat are distinctive from other entities in the set.
These subgroupings become lower-level entity sets that have attributes orparticipate in relationships that do not apply to the higher-level entity set.
Depicted by a trianglecomponent labeled ISA (E.g., instructoris aperson).
Attribute inheritance a lower-level entity set inherits all the attributes
and relationship participation of the higher-level entity set to which it islinked.
Specialization ExampleSpecialization Example
-
8/8/2019 Database Design the Entity Relationship Approach
52/102
Silberschatz, Korth and Sudarshan7.52Database System Concepts - 6th Edition
Specialization ExampleSpecialization Example
Extended ER Features: GeneralizationExtended ER Features: Generalization
-
8/8/2019 Database Design the Entity Relationship Approach
53/102
Silberschatz, Korth and Sudarshan7.53Database System Concepts - 6th Edition
Extended ER Features: GeneralizationExtended ER Features: Generalization
A bottom-up design process combine a number of entity setsthat share the same features into a higher-level entity set.
Specialization and generalization are simple inversions of eachother; they are represented in an E-R diagram in the same way.
The terms specialization and generalization are usedinterchangeably.
Specialization and Generalization (Cont )Specialization and Generalization (Cont )
-
8/8/2019 Database Design the Entity Relationship Approach
54/102
Silberschatz, Korth and Sudarshan7.54Database System Concepts - 6th Edition
Specialization and Generalization (Cont.)Specialization and Generalization (Cont.)
Can have multiple specializations of an entity set based on differentfeatures.
E.g., permanent_employeevs. temporary_employee, in addition toinstructorvs. secretary
Each particular employee would be
a member of one of permanent_employeeor temporary_employee,
and also a member of one of instructor, secretary
The ISA relationship also referred to as superclass - subclassrelationship
Design Constraints on aDesign Constraints on a
-
8/8/2019 Database Design the Entity Relationship Approach
55/102
Silberschatz, Korth and Sudarshan7.55Database System Concepts - 6th Edition
gg
Specialization/GeneralizationSpecialization/Generalization
Constraint on which entities can be members of a given lower-level entityset.
condition-defined
Example: all customers over 65 years are members of senior-citizenentity set; senior-citizenISA person.
user-defined
Constraint on whether or not entities may belong to more than one lower-
level entity set within a single generalization.
Disjoint
an entity can belong to only one lower-level entity set
Noted in E-R diagram by having multiple lower-level entity sets linkto the same triangle
Overlapping
an entity can belong to more than one lower-level entity set
DesignDesign ConstraintsConstraints on aon a
-
8/8/2019 Database Design the Entity Relationship Approach
56/102
Silberschatz, Korth and Sudarshan7.56Database System Concepts - 6th Edition
gg
Specialization/Generalization (Cont.)Specialization/Generalization (Cont.)
Completeness constraint -- specifies whether or not an entity inthe higher-level entity set must belong to at least one of the lower-level entity sets within a generalization.
total: an entity must belong to one of the lower-level entity sets
partial: an entity need not belong to one of the lower-levelentity sets
AggregationAggregation
-
8/8/2019 Database Design the Entity Relationship Approach
57/102
Silberschatz, Korth and Sudarshan7.57Database System Concepts - 6th Edition
AggregationAggregation
Consider the ternary relationship proj_guide, which we saw earlier
Suppose we want to record evaluations of a student by a guide on a
project
Aggregation (Cont )Aggregation (Cont )
-
8/8/2019 Database Design the Entity Relationship Approach
58/102
Silberschatz, Korth and Sudarshan7.58Database System Concepts - 6th Edition
Aggregation (Cont.)Aggregation (Cont.)
Relationship sets eval_forand proj_guiderepresent overlappinginformation
Every eval_forrelationship corresponds to a proj_guiderelationship
However, some proj_guiderelationships may not correspond toany eval_forrelationships
So we cant discard the proj_guiderelationship
Eliminate this redundancy via aggregation
Treat relationship as an abstract entity
Allows relationships between relationships
Abstraction of relationship into new entity
Aggregation (Cont )Aggregation (Cont )
-
8/8/2019 Database Design the Entity Relationship Approach
59/102
Silberschatz, Korth and Sudarshan7.59Database System Concepts - 6th Edition
Aggregation (Cont.)Aggregation (Cont.)
Without introducing redundancy, the following diagram represents:
A student is guided by a particular instructor on a particular project
A student, instructor, project combination may have an associatedevaluation
Representing Specialization viaRepresenting Specialization via
-
8/8/2019 Database Design the Entity Relationship Approach
60/102
Silberschatz, Korth and Sudarshan7.60Database System Concepts - 6th Edition
Representing Specialization viaep ese t g Spec a at o a
SchemasSchemas
Method 1:
Form a schema for the higher-level entity
Form a schema for each lower-level entity set, include primary key
of higher-level entity set and local attributes
schema attributesperson ID, name, street, city
student ID, tot_credemployee ID, salary
Drawback: getting information about, an employeerequiresaccessing two relations, the one corresponding to the low-level
schema and the one corresponding to the high-level schema
-
8/8/2019 Database Design the Entity Relationship Approach
61/102
Schemas Corresponding to AggregationSchemas Corresponding to Aggregation
-
8/8/2019 Database Design the Entity Relationship Approach
62/102
Silberschatz, Korth and Sudarshan7.62Database System Concepts - 6th Edition
Schemas Corresponding to AggregationSchemas Corresponding to Aggregation
To represent aggregation, create a schema containing
primary key of the aggregated relationship,
the primary key of the associated entity set
any descriptive attributes
Schemas Corresponding toSchemas Corresponding to
-
8/8/2019 Database Design the Entity Relationship Approach
63/102
Silberschatz, Korth and Sudarshan7.63Database System Concepts - 6th Edition
Aggregation (Cont.)Aggregation (Cont.)
For example, to represent aggregation manages betweenrelationship works_on and entity set manager, create a schema
eval_for(s_ID, project_id, i_ID, evaluation_id)
Schema proj_guideis redundant provided we are willing to store null
values for attribute manager_namein relation on schema manages
EE--R Design DecisionsR Design Decisions
-
8/8/2019 Database Design the Entity Relationship Approach
64/102
Silberschatz, Korth and Sudarshan7.64Database System Concepts - 6th Edition
EE R Design DecisionsR Design Decisions
The use of an attribute or entity set to represent an object.
Whether a real-world concept is best expressed by an entity set ora relationship set.
The use of a ternary relationship versus a pair of binary
relationships.
The use of a strong or weak entity set.
The use of specialization/generalization contributes to modularity
in the design.
The use of aggregation can treat the aggregate entity set as asingle unit without concern for the details of its internal structure.
-
8/8/2019 Database Design the Entity Relationship Approach
65/102
Database System Concepts, 6th Ed.
Silberschatz, Korth and SudarshanSee www.db-book.com for conditions on re-use
How about doing another ER designHow about doing another ER design
interactively on the board?interactively on the board?
-
8/8/2019 Database Design the Entity Relationship Approach
66/102
Symbols Used in ESymbols Used in E--R Notation (Cont.)R Notation (Cont.)
-
8/8/2019 Database Design the Entity Relationship Approach
67/102
Silberschatz, Korth and Sudarshan7.67Database System Concepts - 6th Edition
Symbols Used in Ey R Notation (Cont.)( )
Alternative ER NotationsAlternative ER Notations
-
8/8/2019 Database Design the Entity Relationship Approach
68/102
Silberschatz, Korth and Sudarshan7.68Database System Concepts - 6th Edition
Alternative ER NotationsAlternative ER Notations
Chen, IDE1FX,
Alternative ER NotationsAlternative ER Notations
-
8/8/2019 Database Design the Entity Relationship Approach
69/102
Silberschatz, Korth and Sudarshan7.69Database System Concepts - 6th Edition
Alternative ER NotationsAlternative ER Notations
Chen IDE1FX (Crows feet notation)
-
8/8/2019 Database Design the Entity Relationship Approach
70/102
-
8/8/2019 Database Design the Entity Relationship Approach
71/102
-
8/8/2019 Database Design the Entity Relationship Approach
72/102
UML Class Diagrams (Cont.)UML Class Diagrams (Cont.)
-
8/8/2019 Database Design the Entity Relationship Approach
73/102
Silberschatz, Korth and Sudarshan7.73Database System Concepts - 6th Edition
U C ass ag a s (Co t )g ( )
Binary relationship sets are represented in UML by just drawing aline connecting the entity sets. The relationship set name is writtenadjacent to the line.
The role played by an entity set in a relationship set may also bespecified by writing the role name on the line, adjacent to the entityset.
The relationship set name may alternatively be written in a box,along with attributes of the relationship set, and the box is
connected, using a dotted line, to the line depicting the relationshipset.
-
8/8/2019 Database Design the Entity Relationship Approach
74/102
Database System Concepts, 6th Ed.
Silberschatz, Korth and SudarshanSee www.db-book.com for conditions on re-use
End of Chapter 7End of Chapter 7
Figure 7.01Figure 7.01
-
8/8/2019 Database Design the Entity Relationship Approach
75/102
Silberschatz, Korth and Sudarshan7.75Database System Concepts - 6th Edition
gg
Figure 7.02Figure 7.02
-
8/8/2019 Database Design the Entity Relationship Approach
76/102
Silberschatz, Korth and Sudarshan7.76Database System Concepts - 6th Edition
gg
Figure 7.03Figure 7.03
-
8/8/2019 Database Design the Entity Relationship Approach
77/102
Silberschatz, Korth and Sudarshan7.77Database System Concepts - 6th Edition
gg
-
8/8/2019 Database Design the Entity Relationship Approach
78/102
Figure 7.05Figure 7.05
-
8/8/2019 Database Design the Entity Relationship Approach
79/102
Silberschatz, Korth and Sudarshan7.79Database System Concepts - 6th Edition
gg
Figure 7.06Figure 7.06
-
8/8/2019 Database Design the Entity Relationship Approach
80/102
Silberschatz, Korth and Sudarshan7.80Database System Concepts - 6th Edition
gg
Figure 7.07Figure 7.07
-
8/8/2019 Database Design the Entity Relationship Approach
81/102
Silberschatz, Korth and Sudarshan7.81Database System Concepts - 6th Edition
gg
Figure 7.08Figure 7.08
-
8/8/2019 Database Design the Entity Relationship Approach
82/102
Silberschatz, Korth and Sudarshan7.82Database System Concepts - 6th Edition
g
Figure 7.09Figure 7.09
-
8/8/2019 Database Design the Entity Relationship Approach
83/102
Silberschatz, Korth and Sudarshan7.83Database System Concepts - 6th Edition
g
Figure 7.10Figure 7.10
-
8/8/2019 Database Design the Entity Relationship Approach
84/102
Silberschatz, Korth and Sudarshan7.84Database System Concepts - 6th Edition
Figure 7.11Figure 7.11
-
8/8/2019 Database Design the Entity Relationship Approach
85/102
Silberschatz, Korth and Sudarshan7.85Database System Concepts - 6th Edition
-
8/8/2019 Database Design the Entity Relationship Approach
86/102
Figure 7.13Figure 7.13
-
8/8/2019 Database Design the Entity Relationship Approach
87/102
Silberschatz, Korth and Sudarshan7.87Database System Concepts - 6th Edition
-
8/8/2019 Database Design the Entity Relationship Approach
88/102
Figure 7.15Figure 7.15
-
8/8/2019 Database Design the Entity Relationship Approach
89/102
Silberschatz, Korth and Sudarshan7.89Database System Concepts - 6th Edition
Figure 7.17Figure 7.17
-
8/8/2019 Database Design the Entity Relationship Approach
90/102
Silberschatz, Korth and Sudarshan7.90Database System Concepts - 6th Edition
-
8/8/2019 Database Design the Entity Relationship Approach
91/102
Figure 7.19Figure 7.19
-
8/8/2019 Database Design the Entity Relationship Approach
92/102
Silberschatz, Korth and Sudarshan7.92Database System Concepts - 6th Edition
Figure 7.20Figure 7.20
-
8/8/2019 Database Design the Entity Relationship Approach
93/102
Silberschatz, Korth and Sudarshan7.93Database System Concepts - 6th Edition
Figure 7.21Figure 7.21
-
8/8/2019 Database Design the Entity Relationship Approach
94/102
Silberschatz, Korth and Sudarshan7.94Database System Concepts - 6th Edition
Figure 7.22Figure 7.22
-
8/8/2019 Database Design the Entity Relationship Approach
95/102
Silberschatz, Korth and Sudarshan7.95Database System Concepts - 6th Edition
Figure 7.23Figure 7.23
-
8/8/2019 Database Design the Entity Relationship Approach
96/102
Silberschatz, Korth and Sudarshan7.96Database System Concepts - 6th Edition
Figure 7.24Figure 7.24
-
8/8/2019 Database Design the Entity Relationship Approach
97/102
Silberschatz, Korth and Sudarshan7.97Database System Concepts - 6th Edition
Figure 7.25Figure 7.25
-
8/8/2019 Database Design the Entity Relationship Approach
98/102
Silberschatz, Korth and Sudarshan7.98Database System Concepts - 6th Edition
Figure 7.26Figure 7.26
-
8/8/2019 Database Design the Entity Relationship Approach
99/102
Silberschatz, Korth and Sudarshan7.99Database System Concepts - 6th Edition
Figure 7.27Figure 7.27
-
8/8/2019 Database Design the Entity Relationship Approach
100/102
Silberschatz, Korth and Sudarshan7.100Database System Concepts - 6th Edition
Figure 7.28Figure 7.28
-
8/8/2019 Database Design the Entity Relationship Approach
101/102
Silberschatz, Korth and Sudarshan7.101Database System Concepts - 6th Edition
-
8/8/2019 Database Design the Entity Relationship Approach
102/102