Download presentation
Presentation is loading. Please wait.
Published bySuzanna Lyons Modified over 9 years ago
1
1 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Session 6 Designing a Database ITE 252 Database Management
2
2 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Homework HW#1: Create an E-R diagram modeled after the Good Reading Bookstores E-R diagram (Figure 3-19 in your text and slide 14 here) for a publisher of music (limit to MP3s). Draw the diagram by hand and write up a description similar to the one in section 3.4.3 (pp.95-95) in your text. Due next class
3
3 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Designing Relational Tables Typical process for converting E-R diagrams to relational tables: – Each entity converts to table – For many-to-many relationships, each associative entity converts to table – Attributes become table columns – Ensure foreign keys appear in proper places in tables To convert single entity, create table of same name with column for each attribute
4
4 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Salesperson Entity and Table
5
5 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Converting Binary Relationships Greater importance in selecting identifier and primary key – Identifier and primary key define foreign key that establishes relationships between tables Often more than one way to represent entity relationships as relational tables
6
6 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Example: Converting 1-1 Binary Relationship
7
7 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Example: Converting 1-1 Binary Relationship
8
8 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Example: Converting 1-1 Binary Relationship
9
9 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Example: Converting 1-1 Binary Relationship Converting one-to-one Salesperson/Office relationship – Options: Convert relationship to single/combined table Convert relationship to two tables
10
10 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Example: Converting 1-1 Binary Relationship Considerations: – Business environment considers Salesperson and Office as separate entities – Modality of zero at Salesperson entity in E-R diagram (office may have no one assigned) – Salesperson entity in E-R diagram has relationships with other entities
11
11 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Example: Converting 1-1 Binary Relationship Solution 1: – Combine two entities into one table
12
12 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Example: Converting 1-1 Binary Relationship Solution 2: – Two separate tables – Office Number as foreign key in Salesperson table
13
13 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Example: Converting 1-1 Binary Relationship Solution 3: – Two separate tables – Salesperson Number as foreign key in Office table
14
14 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting 1-M Binary Relationship
15
15 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting 1-M Binary Relationship Each occurrence of Salesperson is related to zero or more occurrences of Customer Unique identifier of entity on “one” side is placed as foreign key in entity of “many” side
16
16 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting 1-M Binary Relationship
17
17 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting M-M Binary Relationship
18
18 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting M-M Binary Relationship Most relational DBMS systems DO NOT directly support many-to-many relationships Solution: Include associative entity to establish relationship May use composite key as primary key in associative entity A key that is defined by multiple columns is called a composite key
19
19 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting M-M Binary Relationship
20
20 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting M-M Binary Relationship not required
21
21 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting 1-1 Unary Relationship
22
22 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting 1-1 Unary Relationship With: – Only one entity type involved, and – One-to-one relationship Conversion requires only one table
23
23 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting 1-M Unary Relationship each salesperson manages zero or more salespersons each salesperson is managed by a manager
24
24 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting 1-M Unary Relationship each salesperson is managed by a manager
25
25 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting M-M Unary Relationship Many-to-many unary relationship: – For example: one product can be constructed out of set or subset of other products – General rule in conversion: Number of tables equal to number of entity types plus one more table for many-to-many relationship – M-M unary relationship - 2 tables – M-M binary relationship - 3 tables – M-M ternary relationship - 4 four tables
26
26 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting M-M Unary Relationship
27
27 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management Example: Converting M-M Unary Relationship
28
28 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management international, open membership, not- for-profit technology standards consortium. Homework Read Chapter 4.1- pp.104-116
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.