chapter 7: data modeling using the entity relationship (er) model

21
Chapter 7: Data Modeling Using the Entity Relationship (ER) Model

Upload: job-dean

Post on 15-Jan-2016

248 views

Category:

Documents


1 download

TRANSCRIPT

Chapter 7: Data Modeling Using the Entity Relationship (ER) Model

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Database Design Phases

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Instance of entities with attributes

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Composite attribute:

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Entity Type v.s. Entity Set

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Relationship

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Ternary Relationship

Can you think of another example?

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Role name of entity and Recursive Relationship

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Cardinality ratio: 1:1

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Cardinality ratio: M:N

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Continued next page…

Symbols in ER Diagram

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Relationship with higher degree

? why a ≠ b? Find an equivalent binary relationship

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Exercise 1:1.What are the entities in the E-R diagram?2.Which queries could be answered using this database?

a. List all airports (airport_code) in New York State.b. List the airlines with frequent flier program.c. List airplanes (airplane_id) that could land on Minneapolis

Airport.d. List the airplanes (airplane_id) assigned to flight #5 for Delta

Airline.e. List all airports within 500 miles of Minneapolis Airport.f. List flight leg instances which were late by at least on hour.

3.In this database, how many fares are possible for a give flight?(A). at most one; (B). many

4.How many scheduled arrive time could a flight have for a given airport? (A). at most one; (B). many

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

5. Which of the following have unique values in the database?① airport_code② airplane_id③ seat_no.④ leg_no.

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Exercise 2:The database needs to keep track of each U.S. STATE’s Name (e.g., ‘Texas’, ‘New York’, ‘California’) and include the Region of the State (whose domain is {‘Northwest’, ‘Midwest’, ‘Southeast’, ‘Southwest’, ‘West’}). Each CONGRESS_PERSON in the House of Representatives is described by his or her Name, plus the District represented, the Start_Date when the congressperson was first elected, and the political Party to which he or she belongs (whose domain is {‘Republican’, ‘Democrat’, ‘Independent’, ‘Other’}). The database keeps track of each BILL (i.e., proposed law), including the Bill_name, the Data_of_vote on the bill, whether the bill Passed_or_failed (whose domain is ‘yes’ or ‘no’), and the Sponsor (the congressperson(s) who sponsored-that is , proposed-the bill). The database also keeps track of how each congressperson voted on each bill (domain of Vote attribute is {‘yes’, ‘no’, ‘abstain’,’absent’}).

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

1. Identify major entities and their identifying attributes

1. Identify major relationship among entities and their cardinality constraints (1:1, 1:N, M:N)

1. Design an ER schema diagram for this application.