Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2003 Addison-Wesley Your name here. Copyright © 2003 Addison-Wesley Data Modeling with ER Diagrams What is an Entity-Relationship Model? How.

Similar presentations


Presentation on theme: "Copyright © 2003 Addison-Wesley Your name here. Copyright © 2003 Addison-Wesley Data Modeling with ER Diagrams What is an Entity-Relationship Model? How."— Presentation transcript:

1 Copyright © 2003 Addison-Wesley Your name here

2 Copyright © 2003 Addison-Wesley Data Modeling with ER Diagrams What is an Entity-Relationship Model? How is an E-R model represented as an E-R diagram? How can BigHit Video be modeled as an E-R diagram? What is a role in a relationship type? How can we record the history of video rentals? How are cardinalities and related to roles? How can we represent purchase orders? How can we represent time cards and pay statements? What is an object-oriented data model?

3 Copyright © 2003 Addison-Wesley Entity-Relationship Modeling An E-R model is a data model that includes –Entity classes –Attributes of each class –Relationship types between classes –Constraints Types of attributes Designation of key attributes Cardinalities of relationship types An E-R Model is typically represented graphically –E-R diagram, the technique we use –UML diagram, an emerging standard for specifying E-R models and software design

4 Copyright © 2003 Addison-Wesley Entity Relationship Diagrams Sample diagram for entity class Customer

5 Copyright © 2003 Addison-Wesley E-R Diagram for Class Video Sample diagram for entity class Video

6 Copyright © 2003 Addison-Wesley Relationship Types Example of representing relationship type Owns between classes Store and Video

7 Copyright © 2003 Addison-Wesley Constraints on Relationship Types Example of cardinality and participation constraints

8 Copyright © 2003 Addison-Wesley Modeling Video Rentals Examples of current rentals and previous rentals Differences are in cardinalities and attribute names

9 Copyright © 2003 Addison-Wesley Modeling Video Rentals as an Entity Class Diagram shows entity class Rental and its relationship types with Customer and Video Note cardinalities and participation constraints –A Rental entity cannot exist without being related to both a customer and a video Problem occurs because Rental has no key attribute

10 Copyright © 2003 Addison-Wesley Weak Entity Classes A weak entity class is –An entity class with no key of its own –An entity class whose entities cannot exist without being related to other entities An identifying relationship type is –A relationship type that determines the keys of the weak entities

11 Copyright © 2003 Addison-Wesley Roles in Relationship Types Each entity in a relationship plays a specific role in it Roles are particularly important in relationship types that relate an entity class to itself –Each person in an IsChildOf relationship is either a parent or a child

12 Copyright © 2003 Addison-Wesley Employee Roles and Cardinalities Is this an accurate model of the relationships between employees and stores? For example, does this diagram answer these questions correctly? –Does a store have to have a manager? –Can an employee be the manager of more than one store? –What other questions can you ask about roles and cardinalities?

13 Copyright © 2003 Addison-Wesley Purchase Orders What does the diagram below mean? –How do we buy many copies of a single movie? –Does each video have its own videoId before it is received? –What does it mean for an order of a video to have a quantity? The problem with the diagram is with class Video The diagram fails to distinguish between a movie and a copy of a movie (a video) We need to revise the diagram to show Movie as an entity class

14 Copyright © 2003 Addison-Wesley Modeling Videos and Movies This diagram more accurately specifies the true nature of Video and Movie –It also has an accurate specification of PurchaseOrder

15 Copyright © 2003 Addison-Wesley Time Cards and Pay Statements Classes TimeCard and PayStatement are weak Does this diagram show the correct identifying relationships and discriminators? –For example, can an employee have 2 time cards that begin at the same time but are at different stores?

16 Copyright © 2003 Addison-Wesley Adding DVD and Videotape How can we add DVD and videotape to our model? –Do DVD and videotape have different attributes? These diagrams show 2 different models –An entity of class Video can be either a DVD or a videotape (upper diagram) –DVD and Videotape are different entity classes (lower diagram)

17 Copyright © 2003 Addison-Wesley Adding Relationship Types Problems occur when we add relationship types of the data model with separate classes for DVD and Videotape –Relationship types must be duplicated –We cannot enforce constraints

18 Copyright © 2003 Addison-Wesley Modeling with Inheritance Class Video is a common superclass of both DVD and Videotape –Attributes of Video (videoId and dateAcquired) are shared –Relationship types with Rental and Movie are shared –An entity of class Video must be either a DVD or a videotape

19 Copyright © 2003 Addison-Wesley Case in Point E-R Model for Video Sales for BigHit Online Process –Evaluate statement of goals for information system –Evaluate entity classes, attributes and relationship types from Chapter 3 –Draw preliminary E-R diagram with entity classes and their attributes –Add relationship types to E-R diagram –Define cardinality and participation constraints –Add any appropriate inheritance –Evaluate diagram for clarity, accuracy and completeness

20 Copyright © 2003 Addison-Wesley Evaluate Statement of Goals BigHit Video Inc. wants to create an information system for online sales of movies in both DVD and videotape format. People will be allowed to register as customers of the online site and to update their stored information. Information must be maintained about customers’ shipping addresses, e-mail addresses and credit cards. In a single sale, customers will be allowed to purchase any quantity of videos. The items in a single sale will be shipped to a single address and will have a single credit card charge. A customer will be provided with a virtual shopping cart to store items to be purchased. As each item is selected, it is added to the shopping cart. When the customer finishes shopping, he will be directed to a checkout area where payment and shipping information is entered. Once the sale is complete, the customer will be sent a receipt by e-mail.

21 Copyright © 2003 Addison-Wesley Evaluate Entity Classes and Attributes

22 Copyright © 2003 Addison-Wesley Evaluate Relationship Types Relationship TypeEntity Class Cardinality RatioAttibutes PurchasesCustomerSale one-to-many IncludesSaleMovie many-to-many quantity SelectsCustomerShoppingCart one-to-many IncludesShoppingCartMovie many-to-many quantity

23 Copyright © 2003 Addison-Wesley Resulting E-R Diagram for BigHit Online


Download ppt "Copyright © 2003 Addison-Wesley Your name here. Copyright © 2003 Addison-Wesley Data Modeling with ER Diagrams What is an Entity-Relationship Model? How."

Similar presentations


Ads by Google