Top Banner
32

Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

Mar 17, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name
Page 2: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

Goals

• Demonstrate how to build an E-R model from a simple database specification of a video store.

• Use Dia to draw E-R Diagram

Page 3: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

Video store 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 one or multiple VHS, VCD

and DVD formats.and DVD formats.• Each movie belongs to only one of a given

set of categories (action, adventure, comedy…)

Page 4: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

Scenario (cont’d)

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

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

Page 5: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

Scenario (cont’d)

• There are two types of members:– Golden MembersRequire their credit cards and can rent more

than one movies each time.than one movies each time.– Bronze MembersDon’t require their credit cards and can rent

only one movie each time.

Page 6: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

Scenario (cont’d):

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

• Each dependent is allowed to rent one • Each dependent is allowed to rent one movie at a time.

Page 7: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

Draw E-R Diagram using Dia:

• What is Dia?• Dia for Windows

http://dia-installer.sourceforge.net• To launch Dia on lab machines, try• To launch Dia on lab machines, try

dia &dia &

Page 8: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

A video store rents movies to members

Page 9: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name
Page 10: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

Page 11: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name
Page 12: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

A movie can be in one or multiple VHS, VCD, and DVD formats.and DVD formats.

Page 13: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

A movie can be in one or multiple VHS, VCD, and DVD formats.

Page 14: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

Page 15: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

Page 16: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

Page 17: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

Page 18: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

Page 19: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

Provide

Page 20: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

• There are two types of members:– Golden MembersRequire their credit card and can rent more than

one movie each time.one movie each time.– Bronze MembersDon’t require their credit card and can rent only

one movie each time.

Page 21: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

There are two types of members:– Golden Members: provide credit card#– Bronze Members: not provide credit card#

Page 22: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

Page 23: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

Page 24: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

Page 25: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

One idea:

Page 26: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

Each dependent is allowed to rent one movie.Problem:

An attribute can not participate in a relationship!

Page 27: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

• Dependent is an example of Weak Entity– Their existence depends on a strong entity.– 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. – the local attributes that provide individual identity.

Page 28: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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

Page 29: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

Each dependent is allowed to rent only one movie.movie.

Page 30: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

Each dependent is allowed to rent only one movie.

Now dependents CAN participate in a relationship.

Page 31: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name
Page 32: Goals - University of Albertawebdocs.cs.ualberta.ca/~yuan/courses/291/ER-Model.pdf · set of categories (action, adventure, comedy…) Scenario (cont’d) † The store has a name

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 –Pprn219 diagram.ps

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

Room: 1-32 CSCEmail: [email protected]: 492-5067