SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Downloaden Sie, um offline zu lesen
hasen@microcis.net July 21, 2013Hassen poreya
Trainer, Cresco Solution
Afghanistan Workforce
Development Program
Database Design
ER to Relational Mapping
ER to Relational Mapping
 Step 1: Mapping of regular entity type.
 Step 2: Mapping of weak entity type.
 Step 3: Mapping of binary 1:1 relationship types.
 Step 4: Mapping of binary 1:N relationship types.
 Step 5: Mapping of binary N:M relationship types.
 Step 6: Mapping of multivalued attributes.
Mapping of Regular Entity Types
 Step 1: Create relations and attributes for regular
entity types.
 For each regular entity type E in the ER schema, create
a relation R that includes all the simple attributes of E.
 Include only the simple component attributes of a
composite attribute.
 Choose one of the key attributes of E as primary key
for R.
 If the chosen key of E is composite, the set of simple
attributes that form it will together form the primary
key of R.
Example of step 1
 For example, we create the relations EMPLOYEE,
DEPARTMENT, and PROJECT for the regular entity
types EMPLOYEE, DEPARTMENT, and PROJECT in
COMPANY ER schema.
 Then, we choose SSN, DNUMBER and PNUMBER as
primary keys for the relations EMPLOYEE,
DEPARTMENT, and PROJECT, respectively.
 Foreign keys are not included yet.
Step 2: Mapping of Weak Entity Types
 For each weak entity type W in the ER schema with
owner entity type E, create a relation R, and
include all simple attributes of W as attributes of R.
 Include as a foreign key attributes of R the primary
key attribute(s) of the relation(s) that correspond
to the owner entity type(s).
 The primary key of R is the combination of the
primary key(s) of the owner(s) and the partial key
of the weak entity type W.
Example of Step 2
 For example, we create the relation DEPENDENT in
this step.
 Include the primary key SSN of the EMPLOYEE as a
foreign key attribute of DEPENDENT.
 The primary key of DEPENDENT is the combination
{ESSN, DEPENDENT_NAME} because
DEPENDENT_NAME is the partial key of
DEPENDENT.
Step 3: 1:1 relationship type
 For each binary 1:1 relationship type R in the ER
schema, identify the relations S and T that correspond
to the entity types participating in R.
 Choose one of the relations-S, say- and include as
foreign key in S the primary key of T.
 It is better to choose as entity type with total
participation in R.
 Include all the simple attributes of the 1:1 relationship
type R as attributes of S.
 When both participations are total, we may merge the
two entity types and the relationship into a single
relation.
Example of Step 3
 Let’s consider the relationship type MANAGES
which is total.
 Include the primary key of EMPLOYEE as foreign
key in the DEPARTMENT and rename it as
MGRSSN.
Step 4: 1:N relationship type
 For each 1:N relationship type R, identify the
relation S that represents the participating entity
type at the N-side of R.
 Include as foreign key in S the primary key of the
relation T that represents the other entity type
participating in R.
 Include any simple attributes of the 1:N
relationship type as attributes of S.
Example of Step 4
 Let’s consider the 1:N relationships type
WORKS_FOR, and CONTROLS.
 For WORKS_FOR, include the primary key
DNUMBER of DEPARTMENT as foreign key in
EMPLOYEE and call it DNO.
 For CONTROLS, include the primary key DNUMBER
of DEPARTMENT as foreign key in PROJECT and call
it DNUM.
Step 5: M:N relationship type
 For each M:N relationship type R, create a new
relation S to represent R.
 Include as foreign key attributes in S the primary
keys of the relations that represent the
participating entity types; their combination will
form the primary key of S.
 Include any simple attributes of the M:N
relationship type as attributes of S.
 Note: We cannot represent an M:N relationship
type by a single foreign key attribute.
Example of Step 5
 Let consider the M:N relationship type
WORKS_ON.
 Include the primary keys of the PROJECT and
EMPLOYEE relations as foreign keys in WORKS_ON
and rename them as PNO and ESSN, respectively.
 Include an attribute HOURS in WORKS_ON.
Step 6: Multi-valued attributes
 For each multi-valued attribute A, create a new
relation R.
 Include an attribute corresponding to A, plus the
primary key attribute K as a foreign key in R.
 The primary key of R is the combination of A and K.
Example of Step 6
 Let’s consider the attribute DLOCATION.
 Create a relation DEPT_LOCATIONS.
 The primary key of DEPT_LOCATIONS is the
combination of {DNUMBER, DLOCATION}.
Conclusion
 1:1
 Put the primary key of one side to another one as
foreign key.
 1:N
 Put the primary of one side to many (N) side as foreign
key.
 M:N
 Create a new relation (table) and put both primary
keys of relations M and N as foreign key in the new
relation.
Special thanks to Mr. Abdul Rahman Sherzad,
lecturer of Computer Science faculty of Herat
University for giving resource to this lecture.
hasen@microcis.net July 21, 2013Hassen poreya
Trainer, Cresco Solution
Any Questions!
Afghanistan Workforce
Development Program

Weitere ähnliche Inhalte

Andere mochten auch

Web app development_php_05
Web app development_php_05Web app development_php_05
Web app development_php_05Hassen Poreya
 
Web app development_php_04
Web app development_php_04Web app development_php_04
Web app development_php_04Hassen Poreya
 
Web app development_database_design_11
Web app development_database_design_11Web app development_database_design_11
Web app development_database_design_11Hassen Poreya
 
Web app development_database_design_10
Web app development_database_design_10Web app development_database_design_10
Web app development_database_design_10Hassen Poreya
 
Learn to Code with JavaScript - Choose Your Own Adventures
Learn to Code with JavaScript - Choose Your Own AdventuresLearn to Code with JavaScript - Choose Your Own Adventures
Learn to Code with JavaScript - Choose Your Own AdventuresTessa Mero
 
Web app development_my_sql_09
Web app development_my_sql_09Web app development_my_sql_09
Web app development_my_sql_09Hassen Poreya
 
Web app development_html_css_03
Web app development_html_css_03Web app development_html_css_03
Web app development_html_css_03Hassen Poreya
 
Web app development_my_sql_08
Web app development_my_sql_08Web app development_my_sql_08
Web app development_my_sql_08Hassen Poreya
 
Web app development_php_07
Web app development_php_07Web app development_php_07
Web app development_php_07Hassen Poreya
 
Web app development_php_06
Web app development_php_06Web app development_php_06
Web app development_php_06Hassen Poreya
 
Web app development_crud_13
Web app development_crud_13Web app development_crud_13
Web app development_crud_13Hassen Poreya
 
Web app development_html_02
Web app development_html_02Web app development_html_02
Web app development_html_02Hassen Poreya
 
Web app development_cookies_sessions_14
Web app development_cookies_sessions_14Web app development_cookies_sessions_14
Web app development_cookies_sessions_14Hassen Poreya
 
Web app development_html_01
Web app development_html_01Web app development_html_01
Web app development_html_01Hassen Poreya
 

Andere mochten auch (15)

Web app development_php_05
Web app development_php_05Web app development_php_05
Web app development_php_05
 
Web app development_php_04
Web app development_php_04Web app development_php_04
Web app development_php_04
 
Web app development_database_design_11
Web app development_database_design_11Web app development_database_design_11
Web app development_database_design_11
 
Web app development_database_design_10
Web app development_database_design_10Web app development_database_design_10
Web app development_database_design_10
 
Learn to Code with JavaScript - Choose Your Own Adventures
Learn to Code with JavaScript - Choose Your Own AdventuresLearn to Code with JavaScript - Choose Your Own Adventures
Learn to Code with JavaScript - Choose Your Own Adventures
 
Web app development_my_sql_09
Web app development_my_sql_09Web app development_my_sql_09
Web app development_my_sql_09
 
Web app development_html_css_03
Web app development_html_css_03Web app development_html_css_03
Web app development_html_css_03
 
Web app development_my_sql_08
Web app development_my_sql_08Web app development_my_sql_08
Web app development_my_sql_08
 
Web app development_php_07
Web app development_php_07Web app development_php_07
Web app development_php_07
 
Web app development_php_06
Web app development_php_06Web app development_php_06
Web app development_php_06
 
Web app development_crud_13
Web app development_crud_13Web app development_crud_13
Web app development_crud_13
 
CodeIgniter Practice
CodeIgniter PracticeCodeIgniter Practice
CodeIgniter Practice
 
Web app development_html_02
Web app development_html_02Web app development_html_02
Web app development_html_02
 
Web app development_cookies_sessions_14
Web app development_cookies_sessions_14Web app development_cookies_sessions_14
Web app development_cookies_sessions_14
 
Web app development_html_01
Web app development_html_01Web app development_html_01
Web app development_html_01
 

Ähnlich wie Web app development_database_design_er-mapping_12

Pokok Bahasan 06 ER-EER to Relational Mapping (1).pdf
Pokok Bahasan 06 ER-EER to Relational Mapping (1).pdfPokok Bahasan 06 ER-EER to Relational Mapping (1).pdf
Pokok Bahasan 06 ER-EER to Relational Mapping (1).pdfjefrifrans
 
ER model to Relational model mapping
ER model to Relational model mappingER model to Relational model mapping
ER model to Relational model mappingShubham Saini
 
Er & eer to relational mapping
Er & eer to relational mappingEr & eer to relational mapping
Er & eer to relational mappingsaurabhshertukde
 
03 Ch3 Notes Revised
03 Ch3 Notes Revised03 Ch3 Notes Revised
03 Ch3 Notes Revisedguest6f408c
 
ERD with complete knowledge
ERD with complete knowledgeERD with complete knowledge
ERD with complete knowledgeAsma Rasool
 
Design issues with constraints of E-R model
Design issues with constraints of E-R modelDesign issues with constraints of E-R model
Design issues with constraints of E-R modelPaurav Shah
 
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
 
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptxDB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptxZahouAmel1
 
Desigining of Database - ER Model
Desigining of Database - ER ModelDesigining of Database - ER Model
Desigining of Database - ER ModelAjay Chhimpa
 
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
 
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...Mustafa Kamel Mohammadi
 
ECEG 4702-Class7-Entity-Relationship modeling.pptx
ECEG 4702-Class7-Entity-Relationship modeling.pptxECEG 4702-Class7-Entity-Relationship modeling.pptx
ECEG 4702-Class7-Entity-Relationship modeling.pptxmiftah88
 
Data modeling using the entity relationship model
Data modeling using the entity relationship modelData modeling using the entity relationship model
Data modeling using the entity relationship modelJafar Nesargi
 
Relational model
Relational modelRelational model
Relational modelJihin Raju
 

Ähnlich wie Web app development_database_design_er-mapping_12 (20)

Pokok Bahasan 06 ER-EER to Relational Mapping (1).pdf
Pokok Bahasan 06 ER-EER to Relational Mapping (1).pdfPokok Bahasan 06 ER-EER to Relational Mapping (1).pdf
Pokok Bahasan 06 ER-EER to Relational Mapping (1).pdf
 
Mapping example
Mapping exampleMapping example
Mapping example
 
Mapping example
Mapping exampleMapping example
Mapping example
 
Chapter09.ppt
Chapter09.pptChapter09.ppt
Chapter09.ppt
 
ER model to Relational model mapping
ER model to Relational model mappingER model to Relational model mapping
ER model to Relational model mapping
 
Er & eer to relational mapping
Er & eer to relational mappingEr & eer to relational mapping
Er & eer to relational mapping
 
ER to Relational Mapping
ER to Relational MappingER to Relational Mapping
ER to Relational Mapping
 
03 Ch3 Notes Revised
03 Ch3 Notes Revised03 Ch3 Notes Revised
03 Ch3 Notes Revised
 
Chapter3
Chapter3Chapter3
Chapter3
 
Chapter3
Chapter3Chapter3
Chapter3
 
ERD with complete knowledge
ERD with complete knowledgeERD with complete knowledge
ERD with complete knowledge
 
Design issues with constraints of E-R model
Design issues with constraints of E-R modelDesign issues with constraints of E-R model
Design issues with constraints of E-R model
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptxDB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
 
Desigining of Database - ER Model
Desigining of Database - ER ModelDesigining of Database - ER Model
Desigining of Database - ER Model
 
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...
 
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
 
ECEG 4702-Class7-Entity-Relationship modeling.pptx
ECEG 4702-Class7-Entity-Relationship modeling.pptxECEG 4702-Class7-Entity-Relationship modeling.pptx
ECEG 4702-Class7-Entity-Relationship modeling.pptx
 
Data modeling using the entity relationship model
Data modeling using the entity relationship modelData modeling using the entity relationship model
Data modeling using the entity relationship model
 
Relational model
Relational modelRelational model
Relational model
 

Kürzlich hochgeladen

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Kürzlich hochgeladen (20)

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

Web app development_database_design_er-mapping_12

  • 1. hasen@microcis.net July 21, 2013Hassen poreya Trainer, Cresco Solution Afghanistan Workforce Development Program Database Design ER to Relational Mapping
  • 2. ER to Relational Mapping  Step 1: Mapping of regular entity type.  Step 2: Mapping of weak entity type.  Step 3: Mapping of binary 1:1 relationship types.  Step 4: Mapping of binary 1:N relationship types.  Step 5: Mapping of binary N:M relationship types.  Step 6: Mapping of multivalued attributes.
  • 3. Mapping of Regular Entity Types  Step 1: Create relations and attributes for regular entity types.  For each regular entity type E in the ER schema, create a relation R that includes all the simple attributes of E.  Include only the simple component attributes of a composite attribute.  Choose one of the key attributes of E as primary key for R.  If the chosen key of E is composite, the set of simple attributes that form it will together form the primary key of R.
  • 4. Example of step 1  For example, we create the relations EMPLOYEE, DEPARTMENT, and PROJECT for the regular entity types EMPLOYEE, DEPARTMENT, and PROJECT in COMPANY ER schema.  Then, we choose SSN, DNUMBER and PNUMBER as primary keys for the relations EMPLOYEE, DEPARTMENT, and PROJECT, respectively.  Foreign keys are not included yet.
  • 5. Step 2: Mapping of Weak Entity Types  For each weak entity type W in the ER schema with owner entity type E, create a relation R, and include all simple attributes of W as attributes of R.  Include as a foreign key attributes of R the primary key attribute(s) of the relation(s) that correspond to the owner entity type(s).  The primary key of R is the combination of the primary key(s) of the owner(s) and the partial key of the weak entity type W.
  • 6. Example of Step 2  For example, we create the relation DEPENDENT in this step.  Include the primary key SSN of the EMPLOYEE as a foreign key attribute of DEPENDENT.  The primary key of DEPENDENT is the combination {ESSN, DEPENDENT_NAME} because DEPENDENT_NAME is the partial key of DEPENDENT.
  • 7. Step 3: 1:1 relationship type  For each binary 1:1 relationship type R in the ER schema, identify the relations S and T that correspond to the entity types participating in R.  Choose one of the relations-S, say- and include as foreign key in S the primary key of T.  It is better to choose as entity type with total participation in R.  Include all the simple attributes of the 1:1 relationship type R as attributes of S.  When both participations are total, we may merge the two entity types and the relationship into a single relation.
  • 8. Example of Step 3  Let’s consider the relationship type MANAGES which is total.  Include the primary key of EMPLOYEE as foreign key in the DEPARTMENT and rename it as MGRSSN.
  • 9. Step 4: 1:N relationship type  For each 1:N relationship type R, identify the relation S that represents the participating entity type at the N-side of R.  Include as foreign key in S the primary key of the relation T that represents the other entity type participating in R.  Include any simple attributes of the 1:N relationship type as attributes of S.
  • 10. Example of Step 4  Let’s consider the 1:N relationships type WORKS_FOR, and CONTROLS.  For WORKS_FOR, include the primary key DNUMBER of DEPARTMENT as foreign key in EMPLOYEE and call it DNO.  For CONTROLS, include the primary key DNUMBER of DEPARTMENT as foreign key in PROJECT and call it DNUM.
  • 11. Step 5: M:N relationship type  For each M:N relationship type R, create a new relation S to represent R.  Include as foreign key attributes in S the primary keys of the relations that represent the participating entity types; their combination will form the primary key of S.  Include any simple attributes of the M:N relationship type as attributes of S.  Note: We cannot represent an M:N relationship type by a single foreign key attribute.
  • 12. Example of Step 5  Let consider the M:N relationship type WORKS_ON.  Include the primary keys of the PROJECT and EMPLOYEE relations as foreign keys in WORKS_ON and rename them as PNO and ESSN, respectively.  Include an attribute HOURS in WORKS_ON.
  • 13. Step 6: Multi-valued attributes  For each multi-valued attribute A, create a new relation R.  Include an attribute corresponding to A, plus the primary key attribute K as a foreign key in R.  The primary key of R is the combination of A and K.
  • 14. Example of Step 6  Let’s consider the attribute DLOCATION.  Create a relation DEPT_LOCATIONS.  The primary key of DEPT_LOCATIONS is the combination of {DNUMBER, DLOCATION}.
  • 15.
  • 16. Conclusion  1:1  Put the primary key of one side to another one as foreign key.  1:N  Put the primary of one side to many (N) side as foreign key.  M:N  Create a new relation (table) and put both primary keys of relations M and N as foreign key in the new relation.
  • 17. Special thanks to Mr. Abdul Rahman Sherzad, lecturer of Computer Science faculty of Herat University for giving resource to this lecture.
  • 18. hasen@microcis.net July 21, 2013Hassen poreya Trainer, Cresco Solution Any Questions! Afghanistan Workforce Development Program