documenter

31
University of Alberta Department of Computing Science Database Laboratory E-R Modeling: A Case Study E-R Modeling: A Case Study University of Alberta Department of Computing Science CMPUT 291 - File and Database Management Systems

Upload: harini-hari

Post on 28-Nov-2014

41 views

Category:

Documents


2 download

TRANSCRIPT

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

E­R Modeling: A Case Study

University of AlbertaDepartment of Computing Science

CMPUT 291 ­ File and Database Management Systems

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Goals 

● Demonstrate how to build an E-R model from a simple Statement of Objectives of a movie store. ● Use Dia to draw E-R Diagram.

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Scenario: 

● A video store rents movies to members. 

● Each  movie  in  the  store  has  a  title  and  is identified by a unique movie number. 

● A movie can be in VHS, VCD, or DVD format.

● Each  movie  belongs  to  one  of  a  given  set  of categories (action, adventure, comedy, ... )

University of AlbertaDepartment of Computing Science

Database Laboratory 

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Scenario (cont'd): 

● The store has a name and a (unique) phone number for each member. 

● Each  member  may  provide  a  favorite  movie category (used for marketing purposes).

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Scenario (cont'd): 

There are two types of members: 

Golden Members:Require their credit card and can rent more than one movie each time. 

Bronze Members:Don't require their credit card and can rent only one movie each time. 

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Scenario (cont'd): 

● A member may have a number of dependents (with known names). 

● Each dependent is allowed to rent one (1) movie at a time.

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Draw E­R Diagram using Dia:Dia is a program that facilitates drawing charts anddiagrams.

Dia for Windows can be downloaded from:   http://dia­installer.sourceforge.net/

To launch Dia on lab machines, execute the Unix command:.dia &

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

A video store rents movies to members. 

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

A video store rents movies to members. 

Member Movie

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

 Each movie in the store has a title and is identified by a unique movie number. 

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Each movie in the store has a title and is identified by a unique movie number. 

Movie

Title Movie number

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

 A movie can be in VHS, VCD, or DVD format.

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

 A movie can be in VHS, VCD, or DVD format.

Set-valued attribute

Movie

Title Movie number

Format

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

 The store has a name and (unique) phone number for each member. 

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

The  store  has  a  name  and  (unique)  phone  number  for each member. 

Member

NamePhone_number

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Each movie belongs to one of a given set of categories (action, adventure, comedy, ... )

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Each  movie  belongs  to  one  of  a  given  set  of categories (action, adventure, comedy, ... )

BelongsMovie Category

TitleCategory_Text

Format

Movie_number

Dark line means: must belong Arrow means: only one category

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

 Each member may provide one favorite movie category (used for marketing purposes).

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Each member may provide one favorite movie category (used for marketing purposes).

Likes Category

Category_Text

Light line:  may provide Arrow:  one category

Member

Name

Phone_number

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

There are two types of members: 

Golden Members: They must provide their Credit Card number.

Bronze Members: They don't provide their Credit Card number. 

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

There are two types of members: ● Golden Members: They provide their Credit Card number.● Bronze Members: They don't provide their Credit Card number. 

MemberPhone_number Name

IsAFull CoverDisjoints (default)

Golden Member Bronze Member

Credit Card #

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Golden Members can rent more than one movie.Bronze Members can rent only one movie.

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Golden Members can rent more than one movie.Bronze Members can rent only one movie.

G_Rent B_Rent

Member

IsAFull CoverDisjoint (default)

Golden Member Bronze Member

Credit Card #

Movie

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

A member may have a set of dependents (with known names)

MemberPhone_number Name

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

A member may have a set of dependents(with known names). 

Set-valued attribute

MemberPhone_number Name

Dependent

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Each dependent is allowed to rent one (1) movie.

An attribute can not participate in a relationship

MemberPhone_number Name

DependentMovie

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

● dependent is an example of a Weak Entity.> Their existence depends on a strong entity (member).> They usually lack sufficient attributes to form a key.

● Primary key for a weak entity is formed by:> primary key of associated strong entity PLUS> the local attributes that provide individual identity.

Weak Entity Strong EntityOwned By

Weak_Key Strong_Key

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

A member may have a set of dependents (with known names). 

Dependent MemberDep_of

Name Phone_number

Name

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Each dependent is allowed to rent one (1) movie.

University of AlbertaDepartment of Computing Science

Database Laboratory 

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

Each dependent is allowed to rent one (1) movie.

Now dependents CAN participate in a relationship

Dependent MemberDep_of

Name Phone_number

Movie

D_Rent

University of AlbertaDepartment of Computing Science

Database Laboratory E-R Modeling: A Case Study

To print your E-R diagram:● Print to a postscript file (e.g., diagram.ps) in Dia.

✗ Ensure that the diagram fits on one page, first.● At the Unix command prompt, execute the command:

.lpr -Php219 diagram.ps

For printing or any other lab hardware & softwareproblems contact the Help Desk:

Room: 1-49 CSC Email: [email protected] Phone: 492-9219