24
IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Embed Size (px)

Citation preview

Page 1: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

IT354 Database Design

Seminar 5: May 19, 2011

Physical Database Design

Entity-Relationship Diagrams

Page 2: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Activities for this Seminar

• Preliminary Questions• Examine Unit Topics—Seminar Questions• Look at details for Unit 5 Assignment

Page 3: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Preliminary Questions

• Weather check

• Do you have any questions about the web reading articles?

Page 4: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Seminar Questions

•   What data types can you assign to a column in Microsoft Access?  

• How would you go about designing a survey form that you would use to obtain the information from users to design the required database? 

• What information can you display in a Crow's Foot E-R diagram?  

Page 5: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Example data types

Page 6: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Microsoft Access data types

• Found at the following website

• http://msdn.microsoft.com/en-us/library/bb208866%28v=office.12%29.aspx

Page 7: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Unit 5 Assignment

• This is the next step of your final assignment for IT354

• One part (5 points) is incorporating feedback from your instructor. Please do not wait for me to return Unit 4 assignment to start the other parts.

Page 8: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Unit 5 Assignment—three parts

• 1.           Update the three parts of your Unit 4 project, incorporating the feedback from your instructor (5 points)

• 2.            Merge all user views.   Determine all attributes for each table.   Represent all tables using Database Design Language (DBDL)

• Part 2 is worth (25 points)

Page 9: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Unit 5 Assignment

3.  From your DBDL representation, create an Entity-Relationship (E-R) Diagram for your database.   Use the IDEF1X notation used in the textbook. (See Fig. 6.2 and Fig. 6.8.)   Create your E- R Diagram in PowerPoint; change the Page Setup to portrait before you start.   When you are satisfied with your diagram, copy and paste it into your project Word document. (30 points)

Page 10: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

(Shapes to use in ERD)

Entity Weak Associative

Page 11: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Questions

Page 13: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

IT354 Database Design

Enrichment Seminar

ERD

Dr. Laura House

Page 14: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Relationships

How do you determine the type of relationship between two entity types?

To determine the connectivity of a relationship, you make two statements about the relationship, each starting with a singular entity, and examine the (one-word) multiplicity of each. The two statements look at the relationship from each "side."

For example, to examine the relationship between employee and order, the two statements would be:

1. _An_ order is taken by only _one_ employee. (Multiplicity = one.)

2. _An_ employee may take _many_ orders. (Multiplicity = many.)

Page 15: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Relationships, cont

Determining the type of relationship between two entity types, cont.

1. _An_ order is taken by only _one_ employee. (Multiplicity = one.)

2. _An_ employee may take _many_ orders. (Multiplicity = many.)

You combine the two one-word multiplicities to get the connectivity of the relationship. That makes employee to order a one-to-many relationship.

The statement with the multiplicity of "many" is used to determine which is the "one" side and which is the "many" side of the relationship. In this case, Employee is the "one" table and Orders is the "many" table. The primary key (PK) of the "one" table, Employee (e.g. EmployeeID), will be a foreign key (FK) in the "many" table, Orders.

If you carefully make one statement about the relationship from each side starting with a singular, you will get the correct connectivity with no guesswork.

Page 16: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Relationships, cont

Another example:

To determine the relationship between order and product, the two statements would be:

1. _An_ order may contain _many_ products. (Multiplicity = many.)

2. _A_ product may be may be contained in by _many_ orders. (Multiplicity = many.)

Product to Orders would be a many-to-many relationship.

These statements are part of the “business rules.”

Page 17: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Relationships, contAnother example, cont.:

In a relational database, a many-to-many relationship must have an intermediate table called an “associative entity” to link the two entity types.

Product …. 1 : M …. OrderProduct …. M : 1 …. Orders

The OrderProduct associative entity will have the PK of Orders (OrderID) and the PK of Product (ProductID) columns. Each will be a foreign key pointing to their respective “outer” table.

In addition, the two columns will be a composite PK in the OrderProduct table. This table is usually called LineItem or OrderDetail.

Associative entities are usually not depicted in an Enterprise Data Model.

Page 18: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

18

Linking the Tables

• Customer Number is a Primary Key in CUSTOMERS– And a Foreign Key in ORDERS

Page 19: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Question-how do you link these three tables? (before)

• Customer• Name    Address               Zip• Eric         8299 Elk                78250 

• Order• Make    Model   Year• Chevy   S10         2001 

• Payment• Form     Card Number     Balance• Credit    002220022992    2500

 

Page 20: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Question-how do you link these three tables? (after)

• Customer• CustomerID(PK) Name    Address               Zip• 123456 Eric         8299 Elk              78250 

• Order• OrderNumber(PK Make    Model   Year CustomerID• 876654 Chevy   S10         2001 123456 

• Payment• PaymentID Form  Card Number   Balance OrderNum• 000009 Credit    002220022992    2500 876654

 

Page 21: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

What are the entity types? What is the identifier (PK) of each?

Situation and Business Rules

Vintage Music Rocks sells music to customers. The music is on albums. The albums contain several tracks of music.

An album has a catalog number. The catalog number is unique and is determined by the album name and release date.

An album is in one item. An album may be ordered by many customers.

A customer may place multiple orders. A customer may order many albums.

Page 22: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Music

Are these relations in 3NF ?

Customer

ZipCode

Orders

Album

Page 23: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Music

Are these relations in 3NF ?

CustomerCustomerIDName<more>

ZipCodeZipCodeCity

State

OrdersOrderNoCustomerName

Album Name Album Price Order Date Total Price Qty

AlbumCatalogNoAlbumNameAlbum Description

Artist Name Release Date In Stock Value Tracks

Page 24: IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams

Music

Are these relations in 3NF ?

CustomerCustomerIDName<more>

ZipCodeZipCodeCity

State

OrdersOrderNoCustomerName

Order Date

AlbumCatalogNoAlbumNameAlbum Description

Artist Name Release Date In Stock Album Price

AlbumOrdersOrderNoPK CatalogNoPK

Discount

Total Price

Qty

TrackAlbumCatalogNosongnametrack length

Track