Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Chapter 6 Database Design 2: Design Methodology Spring 2006.

Similar presentations


Presentation on theme: "1 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Chapter 6 Database Design 2: Design Methodology Spring 2006."— Presentation transcript:

1 1 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Chapter 6 Database Design 2: Design Methodology Spring 2006

2 2 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Exercise #4 u Due: Feb 22 for full credit, March 1 for 50% credit u Points: 20 points u Pratt & Adamski (End of Chapters 5 & 6) u Assignments must have cover sheet with your name. u Chapter 5 [pp 170-171]: Answer questions 1, 2, 3 for Premiere Products and questions 2, 4 for Henry Books. Omit 4NF, answer the questions for 3NF. u Chapter 6 pp [223-224]: Answer questions 2, 4 for Premiere Products and questions 1, 2, 3 for Henry Books. Turn in ERD and copies of new tables and attributes. (Alternatively, use DBDL.)

3 3 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski One-to-One [1:1] Relationship Considerations u 1:N [maximum cardinality] relationships are the standard. Let’s start by examining how to treat 1:1 relationships u Implementing a one-to-one relationship by simply including the primary key of each table as a foreign key in the other table l A problem is that there is no guarantee that the information will match

4 4 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski 1:1 Relationship Considerations (con’t) u One possible solution is to create a single table. OK? l Although workable, two features are not particularly attractive: 1. Combines columns of two different entities into a single table. Violates “single theme” table notion. 2. If possible for one entity to exist without the other, then this would cause an insertion/deletion anomaly

5 5 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski 1:1 Relationship Considerations (con’t) u Better solution!! l Create two separate tables for Customers and Sales Reps and to include the primary key of one of them as a foreign key in the other l This foreign key would also be designated as an alternate key

6 6 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski 1:1 Relationship Considerations Figure 6.20 (6.25) (4 th Ed.) Include primary key of each table as foreign key in the other. OVERKILL!

7 7 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski 1:1 Relationship Considerations Figure 6.22 Implemented in a single table. Possible Anomalies? Add new Rep: Tyler Harris? What if Tyler has no customers?

8 8 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski 1:1 Relationship Considerations Figure 6.23 1:1 relationship implemented by including primary key of one table as foreign key in ONLY the other.

9 9 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Many-to-Many [N:M] Relationship Considerations u Complex issues arise when more than two entities are related in a N:M relationship [binary relationship] u Many-to-many-to-many [N:M:P] relationship – involves multiple entities [tertiary or higher relationships] u Crucial issue in making the determination between a single many-to-many-to-many relationship and two (or three) many- to-many relationships is the independence of each entity. l Birth [Mother, Father, Child] One vs. multiple relations u Parent:Child vs. Mother:Father:Child

10 10 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Future N:M:P slide u Birth [Mother, Father, Child] vs. … Mom Baby Dad

11 11 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Null Values u Null - a special value (not a blank) u Null - actually represents the absence of a value in a field (undefined) u Nulls - used when a value is either unknown or not applicable [“UNK” or “N/A”] u NULL is a SQL reserved word: SELECT * FROM EMP WHERE PHONENO=NULL;

12 12 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Table Split to Avoid Null Values Figure 6.27 Nulls are absence of values

13 13 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Entity Subtypes u Entity subtype – table that is a subtype of another table u Incomplete category – records that do not fall into the subtype u Complete categories – all records fall into the categories

14 14 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Entity Subtypes Incomplete Categories Figure 6.29

15 15 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Student Table Split into Subtypes Helps to Avoid Nulls Figure 6.31

16 16 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Two Entity Subtypes Complete Categories Figure 6.33

17 17 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Entity-Relationship Model [Chen: Extended ERDs] u Various ERD methodologies use different symbols to represent data; non-standardized notation u E.g., Entities are drawn as rectangles u Relationships are drawn as diamonds with lines connecting the entities involved in relationships

18 18 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski ERD 1:N Relationship Diamond Symbol Figure 6.34 Often 1:N is placed inside the Diamond symbol

19 19 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski ERD 1:N Relationship Crow’s Foot Symbol Figure 6.42

20 20 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski One-to-Many Relationship (with Property/Attribute Ovals) Figure 6.37

21 21 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Many-to-Many Relationship Letter Designators (m:n) Figure 6.35

22 22 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski N:M Relationship with Attributes Figure 6.38

23 23 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Composite Entity u Composite entity - an entity that exists to implement a many-to-many relationship l A.k.a., Intersection Table or Association Table l Essentially both an entity and a relationship l Represented in an E-R diagram by a diamond within a rectangle

24 24 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Composite Entity [OrderLine] Figure 6.39 Attribute Ovals

25 25 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Complete ER Diagram Figure 6.40

26 26 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Maximum & Minimum Cardinality u Maximum Cardinality – the most items that can appear on either side of a relationship u Minimum Cardinality – the least number of items that must be included in a relationship u An entity in a relationship with minimum cardinality of zero plays an optional role in the relationship u An entity with a minimum cardinality of one plays a mandatory role in the relationship

27 27 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Representing Cardinality Figure 6.43

28 28 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Summary u Database design is a two-part process (logical & physical) of determining an appropriate database structure to satisfy a given set of requirements u Entity-relationship (ER) model is a method of representing the structure of a database using an ER diagram (ERD): Examples: ERDx & IDEF1X u A database design is represented in a language called Database Design Language (DDL) u One-to-One [1:1] and One-to-Many [1:N] relationships require attention to primary keys u N:M relationships require Composite tables


Download ppt "1 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Chapter 6 Database Design 2: Design Methodology Spring 2006."

Similar presentations


Ads by Google