SlideShare a Scribd company logo
1 of 31
1
Chapter Six
ER to Relational Mapping
1
Basic terms
SID Name Major GPA
1234 John CS 2.8
5678 Mary EE 3.6
tuple/relational
instance
Attribute
4 Degree
Cardinality=2
A Schema / Relation
2
From ER Model to Relational Mapping
• Mapping: The act of determining how
objects and their relationships are persisted in
permanent data storage in relational
databases.
• Design a relational database schema
• Based on a conceptual and logical schema
design
• Three basic rules to convert ER model into
relations
3
From ER Model to Relational Model
So… how do we convert an ER diagram into a table??
 Rule 1: entity Names will automatically be table names
 Rule 2: Mapping of attributes: attributes will be columns
of the respective tables.
 atomic or single valued or derived or stored attributes
will be columns
 composite attributes: the parent attribute will be
ignored and the decomposed attributes (child
attributes) will be columns of the table.
 Multi- valued attributes: will be mapped to a new table
where the primary key of the main table will be posted
for cross referencing.
 Rule 3: relationships: relation ships will be mapped by
using a foreign key attributes. 4
Example – Strong Entity Set
SID Name Major GPA
1234 John CS 2.8
5678 Mary EE 3.6
Student
SID Name
Major GPA
Advisor Professor
SSN Name
Dept
SSN Name Dept
9999 Smith Math
8888 Lee CS
5
Representation of Weak Entity Set
• Weak Entity Set Cannot exists alone
• To build a table/schema for weak entity
set
– Construct a table with one column for each attribute in
the weak entity set
– Remember to include discriminator
– Augment one extra column on the right side of the
table, put in there the primary key of the Strong Entity
Set (the entity set that the weak entity set is
depending on)
– Primary Key of the weak entity set = Discriminator +
foreign key
6
Example – Weak Entity Set
Age Name Parent_SID
10 Bart 1234
8 Lisa 5678
Student
SID Name
Major GPA
Name
Age
Childrenowns
* Primary key of Children is Parent_SID + Name 7
Representation of Relationship Set
 Unary/Binary Relationship set
 Depends on the cardinality and participation of the relationship
 Two possible approaches
 N-ary (multiple) Relationship set
 Primary Key Issue
 Identifying Relationship
 No relational model representation necessary
8
Representing Relationship Set
Unary/Binary Relationship
• For one-to-one relationship w/out total participation
– Build a table with two columns, one column for each
participating entity set’s primary key. Add successive
columns, one for each descriptive attributes of the
relationship set (if any).
• For one-to-one relationship with one entity set having
total participation
– Augment one extra column on the right side of the
table of the entity set with total participation, put in
there the primary key of the entity set without
complete participation as per to the relationship.
9
Example – One-to-One Relationship Set
SID Maj_ID Co S_Degree
9999 07 1234
8888 05 5678
Student
SID Name
Major GPA
ID Code
Majorstudy
* Primary key can be either SID or Maj_ID_Co
Degree
10
Example – One-to-One Relationship Set
SID Name Major GPA LP_S/N Hav_Cond
9999 Bart Economy -4.0 123-456 Own
8888 Lisa Physics 4.0 567-890 Loan
Student
SID Name
Major GPA
S/N #
LaptopHave
* Primary key can be either SID or LP_S/N
Condition
Brand
1:1
Relationship
11
Representing Relationship Set
Unary/Binary Relationship
• For one-to-many relationship w/out total
participation
– Same thing as one-to-one
• For one-to-many/many-to-one relationship with
one entity set having total participation on
“many” side
– Augment one extra column on the right side of
the table of the entity set on the “many” side,
put in there the primary key of the entity set
on the “one” side as per to the relationship.
12
Example – Many-to-One Relationship Set
SID Name Major GPA Pro_SSN Ad_Sem
9999 Bart Economy -4.0 123-456 Fall 2006
8888 Lisa Physics 4.0 567-890 Fall 2005
Student
SID Name
Major GPA
SSN
Professor
* Primary key of this table is SID
Semester
Name
N:1
Relationship
Dept
Advisor
13
Representing Relationship Set
Unary/Binary Relationship
• For many-to-many relationship
– Same thing as one-to-one relationship without
total participation.
– Primary key of this new schema is the union
of the foreign keys of both entity sets.
– No augmentation approach possible…
14
Representing Relationship Set
N-ary Relationship
– Build a new table with as many columns as there are
attributes for the union of the primary keys of all
participating entity sets.
– Augment additional columns for descriptive attributes
of the relationship set (if necessary)
– The primary key of this table is the union of all
primary keys of entity sets that are on “many” side
– That is it, we are done.
15
Example – N-ary Relationship Set
P-Key1 P-Key2 P-Key3 A-Key D-Attribute
9999 8888 7777 6666 Yes
1234 5678 9012 3456 No
E-Set 1
P-Key1
Another Set
* Primary key of this table is P-Key1 + P-Key2 + P-Key3
D-Attribute
A relationship
A-Key
E-Set 2
P-Key2
E-Set 3
P-Key3
16
Representing Relationship Set
Identifying Relationship
• This is what you have to know
– You DON’T have to build a table/schema for the
identifying relationship set once you have built a
table/schema for the corresponding weak entity set
– Reason:
• A special case of one-to-many with total participation
• Reduce Redundancy
17
Representing Composite Attribute
• Relational Model Indivisibility Rule Applies
• One column for each component attribute
• NO column for the composite attribute itself
Professor
SSN Name
Address
SSN Name Street City
9999 Dr. Smith 50 1st
St. Fake City
8888 Dr. Lee 1 B St. San Jose
Street City
18
Representing Multivalue Attribute
• For each multivalue attribute in an entity
set/relationship set
– Build a new relation schema with two columns
– One column for the primary keys of the entity
set/relationship set that has the multivalue attribute
– Another column for the multivalue attributes. Each
cell of this column holds only one value. So each
value is represented as an unique tuple
– Primary key for this schema is the union of all
attributes
19
Example – Multivalue attribute
SID Name Major GPA
1234 John CS 2.8
5678 Homer EE 3.6
Student
SID Name
Major GPA
Stud_SID Children
1234 Johnson
1234 Mary
5678 Bart
5678 Lisa
5678 Maggie
Children
The primary key for this
table is Student_SID +
Children, the union of all
attributes
20
Mapping EER Model Constructs to
Relations
Options for Mapping Specialization or Generalization.
Convert each specialization with m subclasses {S1, S2,….,Sm} and
generalized superclass C, where the attributes of C are {k,a1,…an} and
k is the (primary) key, into relational schemas using one of the four
following options:
Multiple relations-Superclass and subclasses.
Create a relation L for C with attributes Attrs(L) = {k,a1,…an} and PK(L) = k.
Create a relation Li for each subclass Si, 1 < i < m, with the attributesAttrs(Li) =
{k} U {attributes of Si} and PK(Li)=k. This option works for any specialization
(total or partial, disjoint of over-lapping).
Multiple relations-Subclass relations only
Create a relation Li for each subclass Si, 1 < i < m, with the attributes Attr(Li) =
{attributes of Si} U {k,a1…,an} and PK(Li) = k. This option only works for a
specialization whose subclasses are total (every entity in the superclass must
belong to (at least) one of the subclasses).
21
EER diagram
notation for an
attribute-
defined
specialization
on JobType.
22
Options for mapping specialization or generalization.
(a) Mapping the EER schema.
23
Generalization. (b) Generalizing CAR and TRUCK into the
superclass VEHICLE.
24
Options for mapping specialization or generalization.
(b) Mapping the EER schema .
25
Exercise
• The following ER has been designed to represent
the requirement of an organization to capture
Employee Department and Project information.
And Employee works for department where an
employee might be assigned to manage a
department. Employees might participate on
different projects within the organization. An
employee might as well be assigned to lead a
project where the starting and ending date of
his/her project leadership and bonus will be
registered.
26
27
Answer
28
Answer(cont…)
29
Answer(cont…)
30
Answer(cont…)
31

More Related Content

What's hot

4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraintsKumar
 
Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Eddyzulham Mahluzydde
 
Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)Vidyasagar Mundroy
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relationalJafar Nesargi
 
Relational Model - An Introduction
Relational Model - An IntroductionRelational Model - An Introduction
Relational Model - An IntroductionRajeev Srivastava
 
Chapter-6 Relational Algebra
Chapter-6 Relational AlgebraChapter-6 Relational Algebra
Chapter-6 Relational AlgebraKunal Anand
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model IntroductionNishant Munjal
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]Bashir Rezaie
 
Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraintsNikhil Deswal
 
Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2eidah20
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...Mustafa Kamel Mohammadi
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relationalJafar Nesargi
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...Raj vardhan
 
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database ConstraintsThe Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraintssontumax
 
Lecture 07 relational database management system
Lecture 07 relational database management systemLecture 07 relational database management system
Lecture 07 relational database management systememailharmeet
 
Referential integrity
Referential integrityReferential integrity
Referential integrityJubin Raju
 

What's hot (20)

Relational model
Relational modelRelational model
Relational model
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraints
 
Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1
 
Dbms relational data model and sql queries
Dbms relational data model and sql queries Dbms relational data model and sql queries
Dbms relational data model and sql queries
 
Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
 
Relational Model - An Introduction
Relational Model - An IntroductionRelational Model - An Introduction
Relational Model - An Introduction
 
Chapter-6 Relational Algebra
Chapter-6 Relational AlgebraChapter-6 Relational Algebra
Chapter-6 Relational Algebra
 
Relational model
Relational modelRelational model
Relational model
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
 
Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
 
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database ConstraintsThe Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
 
Lecture 07 relational database management system
Lecture 07 relational database management systemLecture 07 relational database management system
Lecture 07 relational database management system
 
Referential integrity
Referential integrityReferential integrity
Referential integrity
 

Similar to Ch 6

Database management system
Database management systemDatabase management system
Database management systemyash patel
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).pptIshuIswarya3
 
Ch 6 Logical D B Design
Ch 6  Logical D B  DesignCh 6  Logical D B  Design
Ch 6 Logical D B Designguest8fdbdd
 
Note Database Chapter2-Part 1.pdf and presentation
Note Database Chapter2-Part 1.pdf and presentationNote Database Chapter2-Part 1.pdf and presentation
Note Database Chapter2-Part 1.pdf and presentationIqhwanKhairudin1
 
erdiagramspresentation-150826044953-lva1-app6891.pdf
erdiagramspresentation-150826044953-lva1-app6891.pdferdiagramspresentation-150826044953-lva1-app6891.pdf
erdiagramspresentation-150826044953-lva1-app6891.pdfvinayakjadhav94
 
entity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.pptentity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.pptIRWANBINISMAILKPMGur1
 
Download different material from slide share
Download different material from slide shareDownload different material from slide share
Download different material from slide sharefanta teferi
 
Relational model
Relational modelRelational model
Relational modelRUpaliLohar
 
Relational model
Relational modelRelational model
Relational modelRUpaliLohar
 
7. ER Model to Relational Model copy.pdf
7. ER Model to Relational Model copy.pdf7. ER Model to Relational Model copy.pdf
7. ER Model to Relational Model copy.pdfRaksaMa1
 

Similar to Ch 6 (20)

E r model
E r modelE r model
E r model
 
Database management system
Database management systemDatabase management system
Database management system
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).ppt
 
UNIT II DBMS.pptx
UNIT II DBMS.pptxUNIT II DBMS.pptx
UNIT II DBMS.pptx
 
DBMS UNIT1
DBMS UNIT1DBMS UNIT1
DBMS UNIT1
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
DATABASE DESIGN.pptx
DATABASE DESIGN.pptxDATABASE DESIGN.pptx
DATABASE DESIGN.pptx
 
Ch 6 Logical D B Design
Ch 6  Logical D B  DesignCh 6  Logical D B  Design
Ch 6 Logical D B Design
 
Note Database Chapter2-Part 1.pdf and presentation
Note Database Chapter2-Part 1.pdf and presentationNote Database Chapter2-Part 1.pdf and presentation
Note Database Chapter2-Part 1.pdf and presentation
 
erdiagramspresentation-150826044953-lva1-app6891.pdf
erdiagramspresentation-150826044953-lva1-app6891.pdferdiagramspresentation-150826044953-lva1-app6891.pdf
erdiagramspresentation-150826044953-lva1-app6891.pdf
 
Kul 2
Kul 2Kul 2
Kul 2
 
Er diagrams presentation
Er diagrams presentationEr diagrams presentation
Er diagrams presentation
 
Er diagrams presentation
Er diagrams presentationEr diagrams presentation
Er diagrams presentation
 
Relational Model
Relational ModelRelational Model
Relational Model
 
Data Models.pptx
Data Models.pptxData Models.pptx
Data Models.pptx
 
entity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.pptentity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.ppt
 
Download different material from slide share
Download different material from slide shareDownload different material from slide share
Download different material from slide share
 
Relational model
Relational modelRelational model
Relational model
 
Relational model
Relational modelRelational model
Relational model
 
7. ER Model to Relational Model copy.pdf
7. ER Model to Relational Model copy.pdf7. ER Model to Relational Model copy.pdf
7. ER Model to Relational Model copy.pdf
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
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
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
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
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
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
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
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
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
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
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
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
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 

Ch 6

  • 1. 1 Chapter Six ER to Relational Mapping 1
  • 2. Basic terms SID Name Major GPA 1234 John CS 2.8 5678 Mary EE 3.6 tuple/relational instance Attribute 4 Degree Cardinality=2 A Schema / Relation 2
  • 3. From ER Model to Relational Mapping • Mapping: The act of determining how objects and their relationships are persisted in permanent data storage in relational databases. • Design a relational database schema • Based on a conceptual and logical schema design • Three basic rules to convert ER model into relations 3
  • 4. From ER Model to Relational Model So… how do we convert an ER diagram into a table??  Rule 1: entity Names will automatically be table names  Rule 2: Mapping of attributes: attributes will be columns of the respective tables.  atomic or single valued or derived or stored attributes will be columns  composite attributes: the parent attribute will be ignored and the decomposed attributes (child attributes) will be columns of the table.  Multi- valued attributes: will be mapped to a new table where the primary key of the main table will be posted for cross referencing.  Rule 3: relationships: relation ships will be mapped by using a foreign key attributes. 4
  • 5. Example – Strong Entity Set SID Name Major GPA 1234 John CS 2.8 5678 Mary EE 3.6 Student SID Name Major GPA Advisor Professor SSN Name Dept SSN Name Dept 9999 Smith Math 8888 Lee CS 5
  • 6. Representation of Weak Entity Set • Weak Entity Set Cannot exists alone • To build a table/schema for weak entity set – Construct a table with one column for each attribute in the weak entity set – Remember to include discriminator – Augment one extra column on the right side of the table, put in there the primary key of the Strong Entity Set (the entity set that the weak entity set is depending on) – Primary Key of the weak entity set = Discriminator + foreign key 6
  • 7. Example – Weak Entity Set Age Name Parent_SID 10 Bart 1234 8 Lisa 5678 Student SID Name Major GPA Name Age Childrenowns * Primary key of Children is Parent_SID + Name 7
  • 8. Representation of Relationship Set  Unary/Binary Relationship set  Depends on the cardinality and participation of the relationship  Two possible approaches  N-ary (multiple) Relationship set  Primary Key Issue  Identifying Relationship  No relational model representation necessary 8
  • 9. Representing Relationship Set Unary/Binary Relationship • For one-to-one relationship w/out total participation – Build a table with two columns, one column for each participating entity set’s primary key. Add successive columns, one for each descriptive attributes of the relationship set (if any). • For one-to-one relationship with one entity set having total participation – Augment one extra column on the right side of the table of the entity set with total participation, put in there the primary key of the entity set without complete participation as per to the relationship. 9
  • 10. Example – One-to-One Relationship Set SID Maj_ID Co S_Degree 9999 07 1234 8888 05 5678 Student SID Name Major GPA ID Code Majorstudy * Primary key can be either SID or Maj_ID_Co Degree 10
  • 11. Example – One-to-One Relationship Set SID Name Major GPA LP_S/N Hav_Cond 9999 Bart Economy -4.0 123-456 Own 8888 Lisa Physics 4.0 567-890 Loan Student SID Name Major GPA S/N # LaptopHave * Primary key can be either SID or LP_S/N Condition Brand 1:1 Relationship 11
  • 12. Representing Relationship Set Unary/Binary Relationship • For one-to-many relationship w/out total participation – Same thing as one-to-one • For one-to-many/many-to-one relationship with one entity set having total participation on “many” side – Augment one extra column on the right side of the table of the entity set on the “many” side, put in there the primary key of the entity set on the “one” side as per to the relationship. 12
  • 13. Example – Many-to-One Relationship Set SID Name Major GPA Pro_SSN Ad_Sem 9999 Bart Economy -4.0 123-456 Fall 2006 8888 Lisa Physics 4.0 567-890 Fall 2005 Student SID Name Major GPA SSN Professor * Primary key of this table is SID Semester Name N:1 Relationship Dept Advisor 13
  • 14. Representing Relationship Set Unary/Binary Relationship • For many-to-many relationship – Same thing as one-to-one relationship without total participation. – Primary key of this new schema is the union of the foreign keys of both entity sets. – No augmentation approach possible… 14
  • 15. Representing Relationship Set N-ary Relationship – Build a new table with as many columns as there are attributes for the union of the primary keys of all participating entity sets. – Augment additional columns for descriptive attributes of the relationship set (if necessary) – The primary key of this table is the union of all primary keys of entity sets that are on “many” side – That is it, we are done. 15
  • 16. Example – N-ary Relationship Set P-Key1 P-Key2 P-Key3 A-Key D-Attribute 9999 8888 7777 6666 Yes 1234 5678 9012 3456 No E-Set 1 P-Key1 Another Set * Primary key of this table is P-Key1 + P-Key2 + P-Key3 D-Attribute A relationship A-Key E-Set 2 P-Key2 E-Set 3 P-Key3 16
  • 17. Representing Relationship Set Identifying Relationship • This is what you have to know – You DON’T have to build a table/schema for the identifying relationship set once you have built a table/schema for the corresponding weak entity set – Reason: • A special case of one-to-many with total participation • Reduce Redundancy 17
  • 18. Representing Composite Attribute • Relational Model Indivisibility Rule Applies • One column for each component attribute • NO column for the composite attribute itself Professor SSN Name Address SSN Name Street City 9999 Dr. Smith 50 1st St. Fake City 8888 Dr. Lee 1 B St. San Jose Street City 18
  • 19. Representing Multivalue Attribute • For each multivalue attribute in an entity set/relationship set – Build a new relation schema with two columns – One column for the primary keys of the entity set/relationship set that has the multivalue attribute – Another column for the multivalue attributes. Each cell of this column holds only one value. So each value is represented as an unique tuple – Primary key for this schema is the union of all attributes 19
  • 20. Example – Multivalue attribute SID Name Major GPA 1234 John CS 2.8 5678 Homer EE 3.6 Student SID Name Major GPA Stud_SID Children 1234 Johnson 1234 Mary 5678 Bart 5678 Lisa 5678 Maggie Children The primary key for this table is Student_SID + Children, the union of all attributes 20
  • 21. Mapping EER Model Constructs to Relations Options for Mapping Specialization or Generalization. Convert each specialization with m subclasses {S1, S2,….,Sm} and generalized superclass C, where the attributes of C are {k,a1,…an} and k is the (primary) key, into relational schemas using one of the four following options: Multiple relations-Superclass and subclasses. Create a relation L for C with attributes Attrs(L) = {k,a1,…an} and PK(L) = k. Create a relation Li for each subclass Si, 1 < i < m, with the attributesAttrs(Li) = {k} U {attributes of Si} and PK(Li)=k. This option works for any specialization (total or partial, disjoint of over-lapping). Multiple relations-Subclass relations only Create a relation Li for each subclass Si, 1 < i < m, with the attributes Attr(Li) = {attributes of Si} U {k,a1…,an} and PK(Li) = k. This option only works for a specialization whose subclasses are total (every entity in the superclass must belong to (at least) one of the subclasses). 21
  • 22. EER diagram notation for an attribute- defined specialization on JobType. 22
  • 23. Options for mapping specialization or generalization. (a) Mapping the EER schema. 23
  • 24. Generalization. (b) Generalizing CAR and TRUCK into the superclass VEHICLE. 24
  • 25. Options for mapping specialization or generalization. (b) Mapping the EER schema . 25
  • 26. Exercise • The following ER has been designed to represent the requirement of an organization to capture Employee Department and Project information. And Employee works for department where an employee might be assigned to manage a department. Employees might participate on different projects within the organization. An employee might as well be assigned to lead a project where the starting and ending date of his/her project leadership and bonus will be registered. 26
  • 27. 27