Submit Search
Upload
Chap05 c
•
Download as PPT, PDF
•
1 like
•
393 views
A
ahmed naveed
Follow
Logical Database Design and the relation Model.... Modern Database MANagement
Read less
Read more
Education
Report
Share
Report
Share
1 of 56
Download now
Recommended
Transaction in DBMS
Transaction in DBMS
Pyingkodi Maran
Relational model
Relational model
Dabbal Singh Mahara
Lect-4: UML diagrams - Unified Modeling Language - SPM
Lect-4: UML diagrams - Unified Modeling Language - SPM
Mubashir Ali
Enhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) Modeling
sontumax
Relational Database Design
Relational Database Design
Archit Saxena
7. Relational Database Design in DBMS
7. Relational Database Design in DBMS
koolkampus
3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
Relationship Types of degree higher than 2
Relationship Types of degree higher than 2
Aadesh Shrestha
Recommended
Transaction in DBMS
Transaction in DBMS
Pyingkodi Maran
Relational model
Relational model
Dabbal Singh Mahara
Lect-4: UML diagrams - Unified Modeling Language - SPM
Lect-4: UML diagrams - Unified Modeling Language - SPM
Mubashir Ali
Enhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) Modeling
sontumax
Relational Database Design
Relational Database Design
Archit Saxena
7. Relational Database Design in DBMS
7. Relational Database Design in DBMS
koolkampus
3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
Relationship Types of degree higher than 2
Relationship Types of degree higher than 2
Aadesh Shrestha
Entity relationship diagram (erd)
Entity relationship diagram (erd)
tameemyousaf
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and Answers
Abdul Rahman Sherzad
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
Usman Tariq
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
Raj vardhan
Indexing and Hashing
Indexing and Hashing
sathish sak
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
Mohammad Imam Hossain
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
koolkampus
Database Chapter 2
Database Chapter 2
shahadat hossain
Relational Algebra & Calculus
Relational Algebra & Calculus
Abdullah Khosa
DBMS Multiple Choice Questions
DBMS Multiple Choice Questions
Shusil Baral
Dbms relational data model and sql queries
Dbms relational data model and sql queries
Tetala Vishnu Vardhan Reddy
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
Mustafa Kamel Mohammadi
Entity Relationship Diagrams
Entity Relationship Diagrams
sadique_ghitm
Erd examples
Erd examples
Jennifer Polack
Er & eer to relational mapping
Er & eer to relational mapping
saurabhshertukde
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Oum Saokosal
ER to Relational Mapping
ER to Relational Mapping
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
ER to relational Mapping: Data base design using ER to relational language. C...
ER to relational Mapping: Data base design using ER to relational language. C...
Raj vardhan
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS
koolkampus
Enhanced ER(database)
Enhanced ER(database)
welcometofacebook
The Database Environment Chapter 5
The Database Environment Chapter 5
Jeanie Arnoco
Kul 2
Kul 2
sw pitara
More Related Content
What's hot
Entity relationship diagram (erd)
Entity relationship diagram (erd)
tameemyousaf
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and Answers
Abdul Rahman Sherzad
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
Usman Tariq
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
Raj vardhan
Indexing and Hashing
Indexing and Hashing
sathish sak
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
Mohammad Imam Hossain
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
koolkampus
Database Chapter 2
Database Chapter 2
shahadat hossain
Relational Algebra & Calculus
Relational Algebra & Calculus
Abdullah Khosa
DBMS Multiple Choice Questions
DBMS Multiple Choice Questions
Shusil Baral
Dbms relational data model and sql queries
Dbms relational data model and sql queries
Tetala Vishnu Vardhan Reddy
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
Mustafa Kamel Mohammadi
Entity Relationship Diagrams
Entity Relationship Diagrams
sadique_ghitm
Erd examples
Erd examples
Jennifer Polack
Er & eer to relational mapping
Er & eer to relational mapping
saurabhshertukde
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Oum Saokosal
ER to Relational Mapping
ER to Relational Mapping
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
ER to relational Mapping: Data base design using ER to relational language. C...
ER to relational Mapping: Data base design using ER to relational language. C...
Raj vardhan
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS
koolkampus
Enhanced ER(database)
Enhanced ER(database)
welcometofacebook
What's hot
(20)
Entity relationship diagram (erd)
Entity relationship diagram (erd)
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and Answers
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
Indexing and Hashing
Indexing and Hashing
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
Database Chapter 2
Database Chapter 2
Relational Algebra & Calculus
Relational Algebra & Calculus
DBMS Multiple Choice Questions
DBMS Multiple Choice Questions
Dbms relational data model and sql queries
Dbms relational data model and sql queries
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
Entity Relationship Diagrams
Entity Relationship Diagrams
Erd examples
Erd examples
Er & eer to relational mapping
Er & eer to relational mapping
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
ER to Relational Mapping
ER to Relational Mapping
ER to relational Mapping: Data base design using ER to relational language. C...
ER to relational Mapping: Data base design using ER to relational language. C...
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS
Enhanced ER(database)
Enhanced ER(database)
Similar to Chap05 c
The Database Environment Chapter 5
The Database Environment Chapter 5
Jeanie Arnoco
Kul 2
Kul 2
sw pitara
Ch 6 Logical D B Design
Ch 6 Logical D B Design
guest8fdbdd
dbms er model
dbms er model
Surya Swaroop
Note Database Chapter2-Part 1.pdf and presentation
Note Database Chapter2-Part 1.pdf and presentation
IqhwanKhairudin1
ch6
ch6
KITE www.kitecolleges.com
Database Systems - Normalization of Relations(Chapter 4/3)
Database Systems - Normalization of Relations(Chapter 4/3)
Vidyasagar Mundroy
Conceptual Modeling of Data
Conceptual Modeling of Data
M.Zalmai Rahmani
Er
Er
mentorrbuddy
Entity Relationship Model
Entity Relationship Model
Neil Neelesh
L7 er2
L7 er2
Tianlu Wang
Unit 2 DBMS
Unit 2 DBMS
DhivyaSubramaniyam
Eer >r.model
Eer >r.model
lavya3
Test presentation
Test presentation
nuvole
ER model
ER model
paddu123
Er model
Er model
paddu123
dbms
dbms
royalrao85
ER Model and other topics in DBMS
ER Model and other topics in DBMS
HarinarayananR2
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints
Kumar
Unit02 dbms
Unit02 dbms
arnold 7490
Similar to Chap05 c
(20)
The Database Environment Chapter 5
The Database Environment Chapter 5
Kul 2
Kul 2
Ch 6 Logical D B Design
Ch 6 Logical D B Design
dbms er model
dbms er model
Note Database Chapter2-Part 1.pdf and presentation
Note Database Chapter2-Part 1.pdf and presentation
ch6
ch6
Database Systems - Normalization of Relations(Chapter 4/3)
Database Systems - Normalization of Relations(Chapter 4/3)
Conceptual Modeling of Data
Conceptual Modeling of Data
Er
Er
Entity Relationship Model
Entity Relationship Model
L7 er2
L7 er2
Unit 2 DBMS
Unit 2 DBMS
Eer >r.model
Eer >r.model
Test presentation
Test presentation
ER model
ER model
Er model
Er model
dbms
dbms
ER Model and other topics in DBMS
ER Model and other topics in DBMS
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints
Unit02 dbms
Unit02 dbms
Recently uploaded
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
Nbelano25
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
Marc Dusseiller Dusjagr
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Dr Vijay Vishwakarma
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
Celine George
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
akanksha16arora
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
Pooja Bhuva
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
Jisc
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA! .
Colégio Santa Teresinha
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
Elizabeth Walsh
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
Celine George
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
Vivekanand Anglo Vedic Academy
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
stareducators107
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
marlenawright1
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
Esquimalt MFRC
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
Amil baba
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
Jisc
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
Celine George
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
annathomasp01
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Pooja Bhuva
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
Jisc
Recently uploaded
(20)
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA! .
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
Chap05 c
1.
© 2007 by
Prentice Hall© 2007 by Prentice Hall 11 Chapter 5:Chapter 5: Logical Database Design andLogical Database Design and the Relational Modelthe Relational Model Modern Database ManagementModern Database Management 88thth EditionEdition Jeffrey A. Hoffer, Mary B. Prescott,Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFaddenFred R. McFadden
2.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 22 ObjectivesObjectives Definition of termsDefinition of terms List five properties of relationsList five properties of relations State two properties of candidate keysState two properties of candidate keys Define first, second, and third normal formDefine first, second, and third normal form Describe problems from merging relationsDescribe problems from merging relations Transform E-R and EER diagrams to relationsTransform E-R and EER diagrams to relations Create tables with entity and relational integrityCreate tables with entity and relational integrity constraintsconstraints Use normalization to convert anomalous tablesUse normalization to convert anomalous tables to well-structured relationsto well-structured relations
3.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 33 RelationRelation Definition: A relation is a named, two-dimensional table ofDefinition: A relation is a named, two-dimensional table of datadata Table consists of rows (records) and columns (attribute orTable consists of rows (records) and columns (attribute or field)field) Requirements for a table to qualify as a relation:Requirements for a table to qualify as a relation: It must have a unique nameIt must have a unique name Every attribute value must be atomic (not multivalued, notEvery attribute value must be atomic (not multivalued, not composite)composite) Every row must be unique (can’t have two rows with exactly theEvery row must be unique (can’t have two rows with exactly the same values for all their fields)same values for all their fields) Attributes (columns) in tables must have unique namesAttributes (columns) in tables must have unique names The order of the columns must be irrelevantThe order of the columns must be irrelevant The order of the rows must be irrelevantThe order of the rows must be irrelevant NOTE: allNOTE: all relationsrelations are inare in 11stst Normal formNormal form
4.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 44 Correspondence with E-RCorrespondence with E-R ModelModel Relations (tables) correspond with entity typesRelations (tables) correspond with entity types and with many-to-many relationship typesand with many-to-many relationship types Rows correspond with entity instances and withRows correspond with entity instances and with many-to-many relationship instancesmany-to-many relationship instances Columns correspond with attributesColumns correspond with attributes NOTE: The wordNOTE: The word relationrelation (in relational(in relational database) is NOT the same as the worddatabase) is NOT the same as the word relationshiprelationship (in E-R model)(in E-R model)
5.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 55 Key FieldsKey Fields Keys are special fields that serve two main purposes:Keys are special fields that serve two main purposes: Primary keysPrimary keys areare uniqueunique identifiers of the relation in question.identifiers of the relation in question. Examples include employee numbers, social security numbers,Examples include employee numbers, social security numbers, etc.etc. This is how we can guarantee that all rows are uniqueThis is how we can guarantee that all rows are unique Foreign keysForeign keys are identifiers that enable aare identifiers that enable a dependentdependent relationrelation (on the many side of a relationship) to refer to its(on the many side of a relationship) to refer to its parentparent relationrelation (on the one side of the relationship)(on the one side of the relationship) Keys can beKeys can be simplesimple (a single field) or(a single field) or compositecomposite (more than one field)(more than one field) Keys usually are used as indexes to speed up theKeys usually are used as indexes to speed up the response to user queries (More on this in Ch. 6)response to user queries (More on this in Ch. 6)
6.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 66 Primary Key Foreign Key (implements 1:N relationship between customer and order) Combined, these are a composite primary key (uniquely identifies the order line)…individually they are foreign keys (implement M:N relationship between order and product) Figure 5-3 Schema for four relations (Pine Valley Furniture Company)
7.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 77 Integrity ConstraintsIntegrity Constraints Domain ConstraintsDomain Constraints Allowable values for an attribute. See TableAllowable values for an attribute. See Table 5-15-1 Entity IntegrityEntity Integrity No primary key attribute may be null. AllNo primary key attribute may be null. All primary key fieldsprimary key fields MUSTMUST have datahave data Action AssertionsAction Assertions Business rules. Recall from Ch. 4Business rules. Recall from Ch. 4
8.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 88 Domain definitions enforce domain integrity constraints
9.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 99 Integrity ConstraintsIntegrity Constraints Referential Integrity–rule states that any foreign key value (onReferential Integrity–rule states that any foreign key value (on the relation of the many side) MUST match a primary key valuethe relation of the many side) MUST match a primary key value in the relation of the one side. (Or the foreign key can be null)in the relation of the one side. (Or the foreign key can be null) For example: Delete RulesFor example: Delete Rules Restrict–don’t allow delete of “parent” side if related rows exist inRestrict–don’t allow delete of “parent” side if related rows exist in “dependent” side“dependent” side Cascade–automatically delete “dependent” side rows that correspondCascade–automatically delete “dependent” side rows that correspond with the “parent” side row to be deletedwith the “parent” side row to be deleted Set-to-Null–set the foreign key in the dependent side to null ifSet-to-Null–set the foreign key in the dependent side to null if deleting from the parent sidedeleting from the parent side not allowed for weak entitiesnot allowed for weak entities
10.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 1010 Figure 5-5 Referential integrity constraints (Pine Valley Furniture) Referential integrity constraints are drawn via arrows from dependent to parent table
11.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 1111 Figure 5-6 SQL table definitions Referential integrity constraints are implemented with foreign key to primary key references
12.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 1212 Transforming EER DiagramsTransforming EER Diagrams into Relationsinto Relations Mapping Regular Entities to RelationsMapping Regular Entities to Relations 1.1. Simple attributes: E-R attributes map directlySimple attributes: E-R attributes map directly onto the relationonto the relation 2.2. Composite attributes: Use only their simple,Composite attributes: Use only their simple, component attributescomponent attributes 3.3. Multivalued Attribute–Becomes a separateMultivalued Attribute–Becomes a separate relation with a foreign key taken from therelation with a foreign key taken from the superior entitysuperior entity
13.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 1313 (a) CUSTOMER entity type with simple attributes Figure 5-8 Mapping a regular entity (b) CUSTOMER relation
14.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 1414 (a) CUSTOMER entity type with composite attribute Figure 5-9 Mapping a composite attribute (b) CUSTOMER relation with address detail
15.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 1515 Figure 5-10 Mapping an entity with a multivalued attribute One–to–many relationship between original entity and new relation (a) Multivalued attribute becomes a separate relation with foreign key (b)
16.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 1616 Transforming EER DiagramsTransforming EER Diagrams into Relations (cont.)into Relations (cont.) Mapping Weak EntitiesMapping Weak Entities Becomes a separate relation with aBecomes a separate relation with a foreign key taken from the superiorforeign key taken from the superior entityentity Primary key composed of:Primary key composed of: Partial identifier of weak entityPartial identifier of weak entity Primary key of identifying relation (strongPrimary key of identifying relation (strong entity)entity)
17.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 1717 Figure 5-11 Example of mapping a weak entity a) Weak entity DEPENDENT
18.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 1818 NOTE: the domain constraint for the foreign key should NOT allow null value if DEPENDENT is a weak entity Foreign key Composite primary key Figure 5-11 Example of mapping a weak entity (cont.) b) Relations resulting from weak entity
19.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 1919 Transforming EER DiagramsTransforming EER Diagrams into Relations (cont.)into Relations (cont.) Mapping Binary RelationshipsMapping Binary Relationships One-to-Many–Primary key on the one sideOne-to-Many–Primary key on the one side becomes a foreign key on the many sidebecomes a foreign key on the many side Many-to-Many–Create aMany-to-Many–Create a new relationnew relation withwith the primary keys of the two entities as itsthe primary keys of the two entities as its primary keyprimary key One-to-One–Primary key on the mandatoryOne-to-One–Primary key on the mandatory side becomes a foreign key on the optionalside becomes a foreign key on the optional sideside
20.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 2020 Figure 5-12 Example of mapping a 1:M relationship a) Relationship between customers and orders Note the mandatory one b) Mapping the relationship Again, no null value in the foreign key…this is because of the mandatory minimum cardinality Foreign key
21.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 2121 Figure 5-13 Example of mapping an M:N relationship a) Completes relationship (M:N) The Completes relationship will need to become a separate relation
22.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 2222 New intersection relation Foreign key Foreign key Composite primary key Figure 5-13 Example of mapping an M:N relationship (cont.) b) Three resulting relations
23.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 2323 Figure 5-14 Example of mapping a binary 1:1 relationship a) In_charge relationship (1:1) Often in 1:1 relationships, one direction is optional.
24.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 2424 b) Resulting relations Figure 5-14 Example of mapping a binary 1:1 relationship (cont.) Foreign key goes in the relation on the optional side, Matching the primary key on the mandatory side
25.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 2525 Transforming EER DiagramsTransforming EER Diagrams into Relations (cont.)into Relations (cont.) Mapping Associative EntitiesMapping Associative Entities Identifier Not AssignedIdentifier Not Assigned Default primary key for the associationDefault primary key for the association relation is composed of the primary keys ofrelation is composed of the primary keys of the two entities (as in M:N relationship)the two entities (as in M:N relationship) Identifier AssignedIdentifier Assigned It is natural and familiar to end-usersIt is natural and familiar to end-users Default identifier may not be uniqueDefault identifier may not be unique
26.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 2626 Figure 5-15 Example of mapping an associative entity a) An associative entity
27.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 2727 Figure 5-15 Example of mapping an associative entity (cont.) b) Three resulting relations Composite primary key formed from the two foreign keys
28.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 2828 Figure 5-16 Example of mapping an associative entity with an identifier a) SHIPMENT associative entity
29.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 2929 Figure 5-16 Example of mapping an associative entity with an identifier (cont.) b) Three resulting relations Primary key differs from foreign keys
30.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 3030 Transforming EER DiagramsTransforming EER Diagrams into Relations (cont.)into Relations (cont.) Mapping Unary RelationshipsMapping Unary Relationships One-to-Many–Recursive foreign key in theOne-to-Many–Recursive foreign key in the same relationsame relation Many-to-Many–Two relations:Many-to-Many–Two relations: One for the entity typeOne for the entity type One for an associative relation in which theOne for an associative relation in which the primary key has two attributes, both takenprimary key has two attributes, both taken from the primary key of the entityfrom the primary key of the entity
31.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 3131 Figure 5-17 Mapping a unary 1:N relationship (a) EMPLOYEE entity with unary relationship (b) EMPLOYEE relation with recursive foreign key
32.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 3232 Figure 5-18 Mapping a unary M:N relationship (a) Bill-of-materials relationships (M:N) (b) ITEM and COMPONENT relations
33.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 3333 Transforming EER DiagramsTransforming EER Diagrams into Relations (cont.)into Relations (cont.) Mapping Ternary (and n-ary)Mapping Ternary (and n-ary) RelationshipsRelationships One relation for each entity and oneOne relation for each entity and one for the associative entityfor the associative entity Associative entity has foreign keysAssociative entity has foreign keys to each entity in the relationshipto each entity in the relationship
34.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 3434 Figure 5-19 Mapping a ternary relationship a) PATIENT TREATMENT Ternary relationship with associative entity
35.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 3535 b) Mapping the ternary relationship PATIENT TREATMENT Remember that the primary key MUST be unique Figure 5-19 Mapping a ternary relationship (cont.) This is why treatment date and time are included in the composite primary key But this makes a very cumbersome key… It would be better to create a surrogate key like Treatment#
36.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 3636 Transforming EER DiagramsTransforming EER Diagrams into Relations (cont.)into Relations (cont.) Mapping Supertype/Subtype RelationshipsMapping Supertype/Subtype Relationships One relation for supertype and for each subtypeOne relation for supertype and for each subtype Supertype attributes (including identifier andSupertype attributes (including identifier and subtype discriminator) go into supertype relationsubtype discriminator) go into supertype relation Subtype attributes go into each subtype;Subtype attributes go into each subtype; primary key of supertype relation also becomesprimary key of supertype relation also becomes primary key of subtype relationprimary key of subtype relation 1:1 relationship established between supertype1:1 relationship established between supertype and each subtype, with supertype as primaryand each subtype, with supertype as primary tabletable
37.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 3737 Figure 5-20 Supertype/subtype relationships
38.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 3838 Figure 5-21 Mapping Supertype/subtype relationships to relations These are implemented as one-to-one relationships
39.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 3939 Data NormalizationData Normalization Primarily a tool to validate and improvePrimarily a tool to validate and improve a logical design so that it satisfiesa logical design so that it satisfies certain constraints thatcertain constraints that avoidavoid unnecessary duplication ofunnecessary duplication of datadata The process of decomposing relationsThe process of decomposing relations with anomalies to produce smaller,with anomalies to produce smaller, well-structuredwell-structured relationsrelations
40.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 4040 Well-Structured RelationsWell-Structured Relations A relation that contains minimal data redundancy andA relation that contains minimal data redundancy and allows users to insert, delete, and update rowsallows users to insert, delete, and update rows without causing data inconsistencieswithout causing data inconsistencies Goal is to avoid anomaliesGoal is to avoid anomalies Insertion AnomalyInsertion Anomaly –adding new rows forces user to create–adding new rows forces user to create duplicate dataduplicate data Deletion AnomalyDeletion Anomaly –deleting rows may cause a loss of–deleting rows may cause a loss of data that would be needed for other future rowsdata that would be needed for other future rows Modification AnomalyModification Anomaly –changing data in a row forces–changing data in a row forces changes to other rows because of duplicationchanges to other rows because of duplication General rule of thumb: A table should not pertain to more than one entity type
41.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 4141 Example–Figure 5-2bExample–Figure 5-2b Question–Is this a relation? Answer–Yes: Unique rows and no multivalued attributes Question–What’s the primary key? Answer–Composite: Emp_ID, Course_Title
42.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 4242 Anomalies in this TableAnomalies in this Table InsertionInsertion–can’t enter a new employee without–can’t enter a new employee without having the employee take a classhaving the employee take a class DeletionDeletion–if we remove employee 140, we lose–if we remove employee 140, we lose information about the existence of a Tax Acc classinformation about the existence of a Tax Acc class ModificationModification–giving a salary increase to employee–giving a salary increase to employee 100 forces us to update multiple records100 forces us to update multiple records Why do these anomalies exist? Because there are two themes (entity types) in this one relation. This results in data duplication and an unnecessary dependency between the entities
43.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 4343 Functional Dependencies and KeysFunctional Dependencies and Keys Functional Dependency: The value ofFunctional Dependency: The value of one attribute (theone attribute (the determinantdeterminant)) determines the value of anotherdetermines the value of another attributeattribute Candidate Key:Candidate Key: A unique identifier. One of the candidateA unique identifier. One of the candidate keys will become the primary keykeys will become the primary key E.g. perhaps there is both credit card numberE.g. perhaps there is both credit card number and SS# in a table…in this case both areand SS# in a table…in this case both are candidate keyscandidate keys Each non-key field is functionallyEach non-key field is functionally dependent on every candidate keydependent on every candidate key
44.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 4444 Figure 5.22 Steps in normalization
45.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 4545 First Normal FormFirst Normal Form No multivalued attributesNo multivalued attributes Every attribute value is atomicEvery attribute value is atomic Fig. 5-25Fig. 5-25 is notis not in 1in 1stst Normal FormNormal Form (multivalued attributes)(multivalued attributes) it is not ait is not a relationrelation Fig. 5-26Fig. 5-26 isis in 1in 1stst Normal formNormal form All relationsAll relations are in 1are in 1stst NormalNormal FormForm
46.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 4646 Table with multivalued attributes, not in 1st normal form Note: this is NOT a relation
47.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 4747 Table with no multivalued attributes and unique rows, in 1st normal form Note: this is relation, but not a well-structured one
48.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 4848 Anomalies in this TableAnomalies in this Table InsertionInsertion–if new product is ordered for order 1007–if new product is ordered for order 1007 of existing customer, customer data must be re-of existing customer, customer data must be re- entered, causing duplicationentered, causing duplication DeletionDeletion–if we delete the Dining Table from Order–if we delete the Dining Table from Order 1006, we lose information concerning this item's1006, we lose information concerning this item's finish and pricefinish and price UpdateUpdate–changing the price of product ID 4 requires–changing the price of product ID 4 requires update in several recordsupdate in several records Why do these anomalies exist? Because there are multiple themes (entity types) in one relation. This results in duplication and an unnecessary dependency between the entities
49.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 4949 Second Normal FormSecond Normal Form 1NF PLUS1NF PLUS every non-key attributeevery non-key attribute is fully functionally dependent onis fully functionally dependent on the ENTIRE primary keythe ENTIRE primary key Every non-key attribute must be defined byEvery non-key attribute must be defined by the entire key, not by only part of the keythe entire key, not by only part of the key No partial functional dependenciesNo partial functional dependencies
50.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 5050 Order_ID Order_Date, Customer_ID, Customer_Name, Customer_Address Therefore, NOT in 2nd Normal Form Customer_ID Customer_Name, Customer_Address Product_ID Product_Description, Product_Finish, Unit_Price Order_ID, Product_ID Order_Quantity Figure 5-27 Functional dependency diagram for INVOICE
51.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 5151 Partial dependencies are removed, but there are still transitive dependencies Getting it intoGetting it into Second NormalSecond Normal FormForm Figure 5-28 Removing partial dependencies
52.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 5252 Third Normal FormThird Normal Form 2NF PLUS2NF PLUS no transitive dependenciesno transitive dependencies (functional dependencies on non-primary-key(functional dependencies on non-primary-key attributes)attributes) Note: This is called transitive, because theNote: This is called transitive, because the primary key is a determinant for anotherprimary key is a determinant for another attribute, which in turn is a determinant for aattribute, which in turn is a determinant for a thirdthird Solution: Non-key determinant with transitiveSolution: Non-key determinant with transitive dependencies go into a new table; non-keydependencies go into a new table; non-key determinant becomes primary key in the newdeterminant becomes primary key in the new table and stays as foreign key in the old tabletable and stays as foreign key in the old table
53.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 5353 Transitive dependencies are removed Figure 5-28 Removing partial dependencies Getting it intoGetting it into Third NormalThird Normal FormForm
54.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 5454 Merging RelationsMerging Relations View Integration–Combining entities fromView Integration–Combining entities from multiple ER models into common relationsmultiple ER models into common relations Issues to watch out for when merging entitiesIssues to watch out for when merging entities from different ER models:from different ER models: Synonyms–two or more attributes with differentSynonyms–two or more attributes with different names but same meaningnames but same meaning Homonyms–attributes with same name but differentHomonyms–attributes with same name but different meaningsmeanings Transitive dependencies–even if relations are in 3NFTransitive dependencies–even if relations are in 3NF prior to merging, they may not be after mergingprior to merging, they may not be after merging Supertype/subtype relationships–may be hidden priorSupertype/subtype relationships–may be hidden prior to mergingto merging
55.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 5555 Enterprise KeysEnterprise Keys Primary keys that are unique in thePrimary keys that are unique in the whole database, not just within awhole database, not just within a single relationsingle relation Corresponds with the concept of anCorresponds with the concept of an object ID in object-oriented systemsobject ID in object-oriented systems
56.
Chapter 5 ©
2007 by Prentice Hall© 2007 by Prentice Hall 5656 Figure 5-31 Enterprise keys a) Relations with enterprise key b) Sample data with enterprise key
Download now