SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
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

Más contenido relacionado

Destacado (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
 

Similar a 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).pdf
jefrifrans
 
ER model to Relational model mapping
ER model to Relational model mappingER model to Relational model mapping
ER model to Relational model mapping
Shubham Saini
 
Er & eer to relational mapping
Er & eer to relational mappingEr & eer to relational mapping
Er & eer to relational mapping
saurabhshertukde
 
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptxDB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
ZahouAmel1
 
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
miftah88
 
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
Jafar Nesargi
 
Relational model
Relational modelRelational model
Relational model
Jihin Raju
 

Similar a 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
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

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