Sei sulla pagina 1di 31

ER Models ISSUES and Examples

CS263 Lecture 9

ER Issues - Fan Trap


Where a model represents a relationship between entity types, but the pathway between certain entity occurrences is ambiguous. Staff
works for has

Division

operates reports to

Branch

Q. At which branch does employee Fred Bloggs (001) work?

Staff
001 002 003

Division
D1 D2

Branch
B03 B02 B04

A. Fred Bloggs (001) works at Branch B03, or is it B02?

ER Issues - Fan Trap Resolution


We resolve the Fan Trap by restructuring the original ER model to represent the correct association between the entities concerned. Division
operates reports to

Branch

has work for

Staff

Q. At which branch does employee Fred Bloggs (001) work?

Division
D1 D2

Branch
B03 B02 B04

Staff
002 001 003

A. Fred Bloggs (001) works at Branch B02

Developing an ER Diagram
Step 1 Identify Entities  Step 2 Work out relationships  Step 3 Identify Attributes  Step 4 Identify optionality  Step 5 Identify KEY attributes (Resolve any assumptions)


Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Example Problem 1
A college library holds books for its members to borrow. Each book may be written by more than one author. Any one author may have written several books. If no copies of a wanted book are currently in stock, a member may make a reservation for the title until it is available. If books are not returned on time a fine is imposed and if the fine is not paid the member is barred from loaning any other books until the fine is paid.

Member

Book

Author

Title

Member

Book

Author

Title

Member

Book
Serial Number. Condition. Date Purchased.

Author

EACH

Title
Written by Writes Borrows

Member
On loan

Book

Author

Title
RESERVES
Writes Borrows Written by

Member
On loan

Book
FINE

Author

BARRED

Title
Reserves Reserved By Borrows Writes Written by

Member
On loan

Book
MUST

Author

Fine

MAY

ER Diagram One

Title
Reserves Reserved Has Has By Writes Borrows Written by

Member
On loan
Has Imposed on For

Book
Results in

Author

Fine

ER Diagram Two
Reserve

Title
T_A

Member

M_B

Book

Author

Fine

Identify Keys
Reserve

T#

Title
T_A

M#

Member

B#

A#

M_B

Book

Author

F#

Fine

Foreign KeysTwo ER Diagram


M#,T# Reserve

T#

Title

T#,A#

T_A

M#

Member

M#,B# Borrow

B#

T#

A#

Book

Author

F# M#,B#

Fine

Example Problem 2
A global enterprise has three companies, and each company has between two and six departments. Each department employs one or more employees (although certain company employees may not currently be attached to a department), who, as well as possibly having a number of dependants, may well have an associated set of employment history notes. State any assumptions you make.

Company
Belongs to Operates

Employs

Department
Works for

Employee
Belongs to Has

Has Belongs to

Employment Note

Dependent

Example Problem 3
A local authority wishes to keep a database of all its schools and the school children that are attending each school. The system should also be able to record teachers available to be employed at a school and be able to show which teachers teach which children. Each school has one head teacher whos responsibility it is to manage their individual school, this should also be modelled. State any assumptions you make.

School

Teacher

Teaches Taught by

Child

Potrebbero piacerti anche