SlideShare a Scribd company logo
1 of 28
Download to read offline
Database Systems
(SWEG2108)
Chapter – 3
Database Design
Part-II
Chapter 3 Database Design
Relational Integrity Rules (recap)
Mapping ERD to Relational Model
 Step 1: Mapping of Regular Entity Types
 Step 2: Mapping of Weak Entity Types
 Step 3: Mapping of Unary 1:N Relation Types
 Step 4: Mapping of Binary 1:1 Relation Types
 Step 5: Mapping of Binary 1:N Relationship Types
 Step 6: Mapping of Binary M:N Relationship Types
 Step 7: Mapping of Multivalued Attributes
 Step 8: Mapping of N-ary Relationship Types
Database Design 2
Recap Terms
Mapping ERD into Relational model
• converting the conceptual design to a form suitable for relational logical
model, which is in a form of tables.
Database Design 7
Assume this is a pre-college database ER diagram
Mapping ERD into Relational model
1. The basic rule for converting the ER diagrams
into tables
Convert all the Entities in the diagram to
tables
• All the entities represented in the rectangular box
in the ER diagram become independent tables in
the database.
• In the diagram, STUDENT, COURSE, LECTURER and
SUBJECTS forms individual tables
Database Design 8
Mapping ERD into Relational model
1. The basic rule for converting the ER diagrams into
tables
All single valued attributes of an entity is converted
to a column of the table
– All the attributes, whose value at any instance of time is
unique, are considered as columns of that table.
– In the STUDENT Entity, STUDENT_ID, STUDENT_NAME
form the columns of STUDENT table.
– Similarly, LECTURER_ID, LECTURER_NAME form the
columns of LECTURER table. And so on
Database Design 9
Mapping ERD into Relational model
1. The basic rule for converting the ER diagrams into
tables
Declare the foreign key column, if applicable.
– In the diagram, attribute COURSE_ID in the STUDENT entity
is from COURSE entity.
– Hence add COURSE_ID in the STUDENT table and assign it
foreign key constraint.
– COURSE_ID and SUBJECT_ID in LECTURER table forms the
foreign key column.
– Hence by declaring the foreign key constraints, mapping
between the tables are established.
Database Design 10
Mapping ERD into Relational model
1. The basic rule for converting the ER diagrams into tables
Any multi-valued attributes are converted into new table.
– A hobby in the Student table is a multivalued attribute.
• Any student can have any number of hobbies.
– So we cannot represent multiple values in a single column of STUDENT
table.
– We need to store it separately, so that we can store any number of hobbies,
– adding/ removing / deleting hobbies should not create any redundancy or
anomalies in the system.
– Hence we create a separate table STUD_HOBBY with STUDENT_ID and
HOBBY as its columns.
– We create a composite key using both the columns
– STUD_HOBBY(student_id, hobby,…)
Database Design 11
Mapping ERD into Relational model
1. The basic rule for converting the ER diagrams
into tables
Any composite attributes are merged into
same table as different columns.
– In the diagram above, Student Address is a
composite attribute.
– It has Door#, Street, City, State and Pin.
– These attributes are merged into STUDENT table
as individual columns.
Database Design 12
Mapping ERD into Relational model
1. The basic rule for converting the ER diagrams into tables
 One can ignore derived attribute, since it can be calculated
at any time.
– In the STUDENT table, Age can be derived at any point of
time by calculating the difference between yearOfBirth
and current year.
– Hence we need not create a column for this attribute.
– It reduces the duplicity in the database.
Database Design 13
Mapping ERD into Relational model
• The above ERD could be converted into Relationship Diagram as follows
Database Design 14
Mapping ERD into Relational model
2. Let us see some of the special cases
Converting Weak Entity
– Weak entity is also represented as table.
– All the attributes of the weak entity forms the column of
the table.
– But the key attribute represented in the diagram cannot
form the primary key of this table.
– We have to add a foreign key column, which would be the
primary key column of its strong entity.
• This foreign key column along with its key attribute
column forms the primary key of the table.
Database Design 15
Mapping ERD into Relational model
2. Let us see some of the special cases
• Weak entity set always appears in association with
identifying relationship with total participation
• In this case two tables are required
1. A(a1, a2)
2. BR(a1, b1, b2)
Database Design 16
Mapping ERD into Relational model
2. Let us see some of the special cases
• In our example above, SUBJECTS is the weak entity.
• Although, SUBJECT_ID is represented as key attribute in the diagram, it
cannot be considered as primary key.
• In order to add primary key to the column, we have to find the foreign key
first.
• COURSE is the strong entity related to SUBJECT.
– Hence the primary key COURSE_ID of COURSE is added to SUBJECT table as foreign
key.
– Now we can create a composite primary key out of COURSE_ID and SUBJECT_ID.
– Course (COURSE_ID, course_name)
–Subject(key{COURSE_ID(FK), subject_id(partial key)}, subject_name)
Database Design 17
Mapping ERD into Relational model
2. Let us see some of the special cases
• Binary relationship with both cardinality constraints and participation
constraints
Case-1:Binary relationship with cardinality and total participation constraint from one side
Combine the entity set B and relationship set R then two tables will be required:
1. A(a1, a2)
2. BR(a1, b1, b2)
Database Design 18
Mapping ERD into Relational model
2. Let us see some of the special cases
 Case :Binary relationship with cardinality constraint and total
participation from both sides
• Here we need a single table ARB(a1,a2,b1,b2)
• Both a1 and b1 together create primary key
Database Design 19
Mapping ERD into Relational model
2. Let us see some of the special cases
Representing 1:1 relationship
Either of the Two tables are needed
Case 1:
1. AR(a1, a2, b1)
2. B(b1, b2)
Case 2:
1. A(a1, a2)
2. BR(a1, b1, b2)
Database Design 20
Mapping ERD into Relational model
2. Let us see some of the special cases
• Imagine SUBJECT is not a weak entity, and we have LECTURER teaches
SUBJECT relation.
• It is a 1:1 relation. i.e.; one lecturer teaches only one subject.
 We can represent this case in two ways
Case 1:Create table for both LECTURER and SUBJECT.
• Add the primary key of LECTURER in SUBJECT table as foreign key.
• It implies the lecturer name for that particular subject.
Case 2: Create table for both LECTURER and SUBJECT.
• Add the primary key of SUBJECT in LECTURER table as foreign key.
• It implies the subject taught by the lecturer.
Database Design 21
Mapping ERD into Relational model
2. Let us see some of the special cases
• In both the case, meaning is same.
– Foreign key column can be added in either of the table, depending on
the developer’s choice.
• Representing 1:N relationship
Two tables required
1. A(a1, a2)
2. BR(a1, b1, b2)
Database Design 22
Mapping ERD into Relational model
2. Let us see some of the special cases
• Consider SUBJECT and LECTURER relation, where each Lecturer teaches
multiple subjects.
• This is a 1: N relation.
• In this case, primary key of LECTURER table is added to the SUBJECT table.
• i.e.; the primary key at 1 cardinality entity is added as foreign key to N
cardinality entity
Database Design 23
Mapping ERD into Relational model
2. Let us see some of the special cases
Representing M:N relationship
Three tables will be needed
1. A(a1, a2)
2. R(a1, b1)
3. B(b1,b2)
Database Design 24
Mapping ERD into Relational model
2. Let us see some of the special cases
• Consider the example, multiple students enrolled for multiple courses,
– which is M:N relation.
• In this case,
• we create STUDENT and COURSE tables for the entities.
• Create one more table for the relation between them and name it as STUD_COURSE.
• Add the primary keys of COURSE and STUDENT which will become foreign key into it along
with some additional attributes (if applicable) ,
• which forms the composite primary key of the new table.
• Student (student_id, student_name, …)
• Course (course_id, course_name,…)
• Stud_course( student_id , course_id, )
Database Design 25
Mapping ERD into Relational model
2. Let us see some of the special cases
Self referencing 1:1
Database Design 26
Mapping ERD into Relational model
2. Let us see some of the special cases
Self referencing 1:N
Database Design 27
Mapping ERD into Relational model
2. Let us see some of the special cases
Database Design 28

The relationship ‘Contains’ is M:N since a given item can contain
numerous component items, and conversely an item can be used
as a component in numerous other items

Notice that both Item_No and Component_No reference the primary key
(Item_No) of the ITEM relation
Activity Exercise
• Convert the following ERD into Relationship diagram
Database Design 29
Note: This to correct that "name" in entity department
and project is not underlined. That means, name is not
a part of the primary key.
Database Design 31
Possible Relationship diagram for the
ERD on the previous slide
Home Work: Can you construct the entire the mapped ER schema of the ER Diagram shown on Slide #7. i.e. Pre-College database.

More Related Content

Similar to Chapter – 3 Database Design P-II.pdf

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
 
Eer >r.model
Eer >r.modelEer >r.model
Eer >r.modellavya3
 
Logical database design and the relational model(database)
Logical database design and the relational model(database)Logical database design and the relational model(database)
Logical database design and the relational model(database)welcometofacebook
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelKunal Anand
 
Mapping object to_data_models_with_the_uml
Mapping object to_data_models_with_the_umlMapping object to_data_models_with_the_uml
Mapping object to_data_models_with_the_umlIvan Paredes
 
Advance database system(part 5)
Advance database system(part 5)Advance database system(part 5)
Advance database system(part 5)Abdullah Khosa
 
Understanding about relational database m-square systems inc
Understanding about relational database m-square systems incUnderstanding about relational database m-square systems inc
Understanding about relational database m-square systems incMuthu Natarajan
 
Module 4_PART1.pptx
Module 4_PART1.pptxModule 4_PART1.pptx
Module 4_PART1.pptxHaso12
 
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptxDB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptxZahouAmel1
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).pptIshuIswarya3
 
Download different material from slide share
Download different material from slide shareDownload different material from slide share
Download different material from slide sharefanta teferi
 
Enhanced E-R diagram
Enhanced E-R diagramEnhanced E-R diagram
Enhanced E-R diagramMayank Jain
 

Similar to Chapter – 3 Database Design P-II.pdf (20)

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
 
2 rel-algebra
2 rel-algebra2 rel-algebra
2 rel-algebra
 
Eer >r.model
Eer >r.modelEer >r.model
Eer >r.model
 
Logical database design and the relational model(database)
Logical database design and the relational model(database)Logical database design and the relational model(database)
Logical database design and the relational model(database)
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data Model
 
Mapping object to_data_models_with_the_uml
Mapping object to_data_models_with_the_umlMapping object to_data_models_with_the_uml
Mapping object to_data_models_with_the_uml
 
Advance database system(part 5)
Advance database system(part 5)Advance database system(part 5)
Advance database system(part 5)
 
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
 
Unit03 dbms
Unit03 dbmsUnit03 dbms
Unit03 dbms
 
Understanding about relational database m-square systems inc
Understanding about relational database m-square systems incUnderstanding about relational database m-square systems inc
Understanding about relational database m-square systems inc
 
uniT 4 (1).pptx
uniT 4 (1).pptxuniT 4 (1).pptx
uniT 4 (1).pptx
 
week 7 normalization.pptx
week 7 normalization.pptxweek 7 normalization.pptx
week 7 normalization.pptx
 
Module 4_PART1.pptx
Module 4_PART1.pptxModule 4_PART1.pptx
Module 4_PART1.pptx
 
Normalization in Database
Normalization in DatabaseNormalization in Database
Normalization in Database
 
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptxDB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).ppt
 
Kul 2
Kul 2Kul 2
Kul 2
 
DBMS-Unit-2.pptx
DBMS-Unit-2.pptxDBMS-Unit-2.pptx
DBMS-Unit-2.pptx
 
Download different material from slide share
Download different material from slide shareDownload different material from slide share
Download different material from slide share
 
Enhanced E-R diagram
Enhanced E-R diagramEnhanced E-R diagram
Enhanced E-R diagram
 

More from TamiratDejene1

Congestion Control and QOS.ppt
Congestion Control and QOS.pptCongestion Control and QOS.ppt
Congestion Control and QOS.pptTamiratDejene1
 
Analog Transmission.ppt
Analog Transmission.pptAnalog Transmission.ppt
Analog Transmission.pptTamiratDejene1
 
Chapter 5 (Part I) - Pointers.pdf
Chapter 5 (Part I) - Pointers.pdfChapter 5 (Part I) - Pointers.pdf
Chapter 5 (Part I) - Pointers.pdfTamiratDejene1
 
Chapter 7 (Part I) - User Defined Datatypes.pdf
Chapter 7 (Part I) - User Defined Datatypes.pdfChapter 7 (Part I) - User Defined Datatypes.pdf
Chapter 7 (Part I) - User Defined Datatypes.pdfTamiratDejene1
 
00-intro-to-classes.pdf
00-intro-to-classes.pdf00-intro-to-classes.pdf
00-intro-to-classes.pdfTamiratDejene1
 
Chapter 8_Shift Registers (EEEg4302)1.pdf
Chapter 8_Shift Registers (EEEg4302)1.pdfChapter 8_Shift Registers (EEEg4302)1.pdf
Chapter 8_Shift Registers (EEEg4302)1.pdfTamiratDejene1
 
Chapter 7_Counters (EEEg4302).pdf
Chapter 7_Counters (EEEg4302).pdfChapter 7_Counters (EEEg4302).pdf
Chapter 7_Counters (EEEg4302).pdfTamiratDejene1
 
Chapter 5_combinational logic (EEEg4302).pdf
Chapter 5_combinational logic (EEEg4302).pdfChapter 5_combinational logic (EEEg4302).pdf
Chapter 5_combinational logic (EEEg4302).pdfTamiratDejene1
 
Chapter 3_Logic Gates (EEEg4302).pdf
Chapter 3_Logic Gates (EEEg4302).pdfChapter 3_Logic Gates (EEEg4302).pdf
Chapter 3_Logic Gates (EEEg4302).pdfTamiratDejene1
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfTamiratDejene1
 
Chapter 1_Introduction to digital design (EEEg4302).pdf
Chapter 1_Introduction to digital design (EEEg4302).pdfChapter 1_Introduction to digital design (EEEg4302).pdf
Chapter 1_Introduction to digital design (EEEg4302).pdfTamiratDejene1
 

More from TamiratDejene1 (20)

Ch-3 lecture.pdf
Ch-3 lecture.pdfCh-3 lecture.pdf
Ch-3 lecture.pdf
 
Chapter 2.pptx
Chapter 2.pptxChapter 2.pptx
Chapter 2.pptx
 
Wireless LANs.ppt
Wireless LANs.pptWireless LANs.ppt
Wireless LANs.ppt
 
Data Link Control.ppt
Data Link Control.pptData Link Control.ppt
Data Link Control.ppt
 
Congestion Control and QOS.ppt
Congestion Control and QOS.pptCongestion Control and QOS.ppt
Congestion Control and QOS.ppt
 
Analog Transmission.ppt
Analog Transmission.pptAnalog Transmission.ppt
Analog Transmission.ppt
 
Chapter 5 (Part I) - Pointers.pdf
Chapter 5 (Part I) - Pointers.pdfChapter 5 (Part I) - Pointers.pdf
Chapter 5 (Part I) - Pointers.pdf
 
Chapter 7 (Part I) - User Defined Datatypes.pdf
Chapter 7 (Part I) - User Defined Datatypes.pdfChapter 7 (Part I) - User Defined Datatypes.pdf
Chapter 7 (Part I) - User Defined Datatypes.pdf
 
00-intro-to-classes.pdf
00-intro-to-classes.pdf00-intro-to-classes.pdf
00-intro-to-classes.pdf
 
DLD Chapter-5.pdf
DLD Chapter-5.pdfDLD Chapter-5.pdf
DLD Chapter-5.pdf
 
DLD Chapter-4.pdf
DLD Chapter-4.pdfDLD Chapter-4.pdf
DLD Chapter-4.pdf
 
DLD Chapter-2.pdf
DLD Chapter-2.pdfDLD Chapter-2.pdf
DLD Chapter-2.pdf
 
DLD Chapter-1.pdf
DLD Chapter-1.pdfDLD Chapter-1.pdf
DLD Chapter-1.pdf
 
DLD_Chapter_1.pdf
DLD_Chapter_1.pdfDLD_Chapter_1.pdf
DLD_Chapter_1.pdf
 
Chapter 8_Shift Registers (EEEg4302)1.pdf
Chapter 8_Shift Registers (EEEg4302)1.pdfChapter 8_Shift Registers (EEEg4302)1.pdf
Chapter 8_Shift Registers (EEEg4302)1.pdf
 
Chapter 7_Counters (EEEg4302).pdf
Chapter 7_Counters (EEEg4302).pdfChapter 7_Counters (EEEg4302).pdf
Chapter 7_Counters (EEEg4302).pdf
 
Chapter 5_combinational logic (EEEg4302).pdf
Chapter 5_combinational logic (EEEg4302).pdfChapter 5_combinational logic (EEEg4302).pdf
Chapter 5_combinational logic (EEEg4302).pdf
 
Chapter 3_Logic Gates (EEEg4302).pdf
Chapter 3_Logic Gates (EEEg4302).pdfChapter 3_Logic Gates (EEEg4302).pdf
Chapter 3_Logic Gates (EEEg4302).pdf
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
 
Chapter 1_Introduction to digital design (EEEg4302).pdf
Chapter 1_Introduction to digital design (EEEg4302).pdfChapter 1_Introduction to digital design (EEEg4302).pdf
Chapter 1_Introduction to digital design (EEEg4302).pdf
 

Recently uploaded

定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一ffjhghh
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 

Recently uploaded (20)

定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 

Chapter – 3 Database Design P-II.pdf

  • 1. Database Systems (SWEG2108) Chapter – 3 Database Design Part-II
  • 2. Chapter 3 Database Design Relational Integrity Rules (recap) Mapping ERD to Relational Model  Step 1: Mapping of Regular Entity Types  Step 2: Mapping of Weak Entity Types  Step 3: Mapping of Unary 1:N Relation Types  Step 4: Mapping of Binary 1:1 Relation Types  Step 5: Mapping of Binary 1:N Relationship Types  Step 6: Mapping of Binary M:N Relationship Types  Step 7: Mapping of Multivalued Attributes  Step 8: Mapping of N-ary Relationship Types Database Design 2
  • 4. Mapping ERD into Relational model • converting the conceptual design to a form suitable for relational logical model, which is in a form of tables. Database Design 7 Assume this is a pre-college database ER diagram
  • 5. Mapping ERD into Relational model 1. The basic rule for converting the ER diagrams into tables Convert all the Entities in the diagram to tables • All the entities represented in the rectangular box in the ER diagram become independent tables in the database. • In the diagram, STUDENT, COURSE, LECTURER and SUBJECTS forms individual tables Database Design 8
  • 6. Mapping ERD into Relational model 1. The basic rule for converting the ER diagrams into tables All single valued attributes of an entity is converted to a column of the table – All the attributes, whose value at any instance of time is unique, are considered as columns of that table. – In the STUDENT Entity, STUDENT_ID, STUDENT_NAME form the columns of STUDENT table. – Similarly, LECTURER_ID, LECTURER_NAME form the columns of LECTURER table. And so on Database Design 9
  • 7. Mapping ERD into Relational model 1. The basic rule for converting the ER diagrams into tables Declare the foreign key column, if applicable. – In the diagram, attribute COURSE_ID in the STUDENT entity is from COURSE entity. – Hence add COURSE_ID in the STUDENT table and assign it foreign key constraint. – COURSE_ID and SUBJECT_ID in LECTURER table forms the foreign key column. – Hence by declaring the foreign key constraints, mapping between the tables are established. Database Design 10
  • 8. Mapping ERD into Relational model 1. The basic rule for converting the ER diagrams into tables Any multi-valued attributes are converted into new table. – A hobby in the Student table is a multivalued attribute. • Any student can have any number of hobbies. – So we cannot represent multiple values in a single column of STUDENT table. – We need to store it separately, so that we can store any number of hobbies, – adding/ removing / deleting hobbies should not create any redundancy or anomalies in the system. – Hence we create a separate table STUD_HOBBY with STUDENT_ID and HOBBY as its columns. – We create a composite key using both the columns – STUD_HOBBY(student_id, hobby,…) Database Design 11
  • 9. Mapping ERD into Relational model 1. The basic rule for converting the ER diagrams into tables Any composite attributes are merged into same table as different columns. – In the diagram above, Student Address is a composite attribute. – It has Door#, Street, City, State and Pin. – These attributes are merged into STUDENT table as individual columns. Database Design 12
  • 10. Mapping ERD into Relational model 1. The basic rule for converting the ER diagrams into tables  One can ignore derived attribute, since it can be calculated at any time. – In the STUDENT table, Age can be derived at any point of time by calculating the difference between yearOfBirth and current year. – Hence we need not create a column for this attribute. – It reduces the duplicity in the database. Database Design 13
  • 11. Mapping ERD into Relational model • The above ERD could be converted into Relationship Diagram as follows Database Design 14
  • 12. Mapping ERD into Relational model 2. Let us see some of the special cases Converting Weak Entity – Weak entity is also represented as table. – All the attributes of the weak entity forms the column of the table. – But the key attribute represented in the diagram cannot form the primary key of this table. – We have to add a foreign key column, which would be the primary key column of its strong entity. • This foreign key column along with its key attribute column forms the primary key of the table. Database Design 15
  • 13. Mapping ERD into Relational model 2. Let us see some of the special cases • Weak entity set always appears in association with identifying relationship with total participation • In this case two tables are required 1. A(a1, a2) 2. BR(a1, b1, b2) Database Design 16
  • 14. Mapping ERD into Relational model 2. Let us see some of the special cases • In our example above, SUBJECTS is the weak entity. • Although, SUBJECT_ID is represented as key attribute in the diagram, it cannot be considered as primary key. • In order to add primary key to the column, we have to find the foreign key first. • COURSE is the strong entity related to SUBJECT. – Hence the primary key COURSE_ID of COURSE is added to SUBJECT table as foreign key. – Now we can create a composite primary key out of COURSE_ID and SUBJECT_ID. – Course (COURSE_ID, course_name) –Subject(key{COURSE_ID(FK), subject_id(partial key)}, subject_name) Database Design 17
  • 15. Mapping ERD into Relational model 2. Let us see some of the special cases • Binary relationship with both cardinality constraints and participation constraints Case-1:Binary relationship with cardinality and total participation constraint from one side Combine the entity set B and relationship set R then two tables will be required: 1. A(a1, a2) 2. BR(a1, b1, b2) Database Design 18
  • 16. Mapping ERD into Relational model 2. Let us see some of the special cases  Case :Binary relationship with cardinality constraint and total participation from both sides • Here we need a single table ARB(a1,a2,b1,b2) • Both a1 and b1 together create primary key Database Design 19
  • 17. Mapping ERD into Relational model 2. Let us see some of the special cases Representing 1:1 relationship Either of the Two tables are needed Case 1: 1. AR(a1, a2, b1) 2. B(b1, b2) Case 2: 1. A(a1, a2) 2. BR(a1, b1, b2) Database Design 20
  • 18. Mapping ERD into Relational model 2. Let us see some of the special cases • Imagine SUBJECT is not a weak entity, and we have LECTURER teaches SUBJECT relation. • It is a 1:1 relation. i.e.; one lecturer teaches only one subject.  We can represent this case in two ways Case 1:Create table for both LECTURER and SUBJECT. • Add the primary key of LECTURER in SUBJECT table as foreign key. • It implies the lecturer name for that particular subject. Case 2: Create table for both LECTURER and SUBJECT. • Add the primary key of SUBJECT in LECTURER table as foreign key. • It implies the subject taught by the lecturer. Database Design 21
  • 19. Mapping ERD into Relational model 2. Let us see some of the special cases • In both the case, meaning is same. – Foreign key column can be added in either of the table, depending on the developer’s choice. • Representing 1:N relationship Two tables required 1. A(a1, a2) 2. BR(a1, b1, b2) Database Design 22
  • 20. Mapping ERD into Relational model 2. Let us see some of the special cases • Consider SUBJECT and LECTURER relation, where each Lecturer teaches multiple subjects. • This is a 1: N relation. • In this case, primary key of LECTURER table is added to the SUBJECT table. • i.e.; the primary key at 1 cardinality entity is added as foreign key to N cardinality entity Database Design 23
  • 21. Mapping ERD into Relational model 2. Let us see some of the special cases Representing M:N relationship Three tables will be needed 1. A(a1, a2) 2. R(a1, b1) 3. B(b1,b2) Database Design 24
  • 22. Mapping ERD into Relational model 2. Let us see some of the special cases • Consider the example, multiple students enrolled for multiple courses, – which is M:N relation. • In this case, • we create STUDENT and COURSE tables for the entities. • Create one more table for the relation between them and name it as STUD_COURSE. • Add the primary keys of COURSE and STUDENT which will become foreign key into it along with some additional attributes (if applicable) , • which forms the composite primary key of the new table. • Student (student_id, student_name, …) • Course (course_id, course_name,…) • Stud_course( student_id , course_id, ) Database Design 25
  • 23. Mapping ERD into Relational model 2. Let us see some of the special cases Self referencing 1:1 Database Design 26
  • 24. Mapping ERD into Relational model 2. Let us see some of the special cases Self referencing 1:N Database Design 27
  • 25. Mapping ERD into Relational model 2. Let us see some of the special cases Database Design 28  The relationship ‘Contains’ is M:N since a given item can contain numerous component items, and conversely an item can be used as a component in numerous other items  Notice that both Item_No and Component_No reference the primary key (Item_No) of the ITEM relation
  • 26. Activity Exercise • Convert the following ERD into Relationship diagram Database Design 29 Note: This to correct that "name" in entity department and project is not underlined. That means, name is not a part of the primary key.
  • 27.
  • 28. Database Design 31 Possible Relationship diagram for the ERD on the previous slide Home Work: Can you construct the entire the mapped ER schema of the ER Diagram shown on Slide #7. i.e. Pre-College database.