lecture 9 notes

31
ER Models ISSUES and Examples CS263 Lecture 9

Upload: bahati-mugini

Post on 13-Nov-2015

216 views

Category:

Documents


0 download

DESCRIPTION

balis 3

TRANSCRIPT

  • ER Models

    ISSUESand Examples

    CS263 Lecture 9

  • ER Issues - Fan TrapWhere a model represents a relationship between entity types, but the pathway between certain entity occurrences is ambiguous.Q. At which branch does employee Fred Bloggs (001) work?StaffBranchworks forhasDivisionoperatesreports toStaff001002003DivisionD1D2BranchB03B02B04A. Fred Bloggs (001) works at Branch B03, or is it B02?

  • ER Issues - Fan Trap ResolutionWe resolve the Fan Trap by restructuring the original ER model to represent the correct association between the entities concerned.Q. At which branch does employee Fred Bloggs (001) work?DivisionStaffwork forhasBranchoperatesreports toA. Fred Bloggs (001) works at Branch B02

  • Developing an ER DiagramStep 1Identify EntitiesStep 2Work out relationshipsStep 3Identify AttributesStep 4Identify optionalityStep 5Identify KEY attributes(Resolve any assumptions)

  • Example Problem 1A 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 1A 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 1A 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 1A 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 1A 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 1A 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 1A 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 1A 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 1A 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 1A 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 1A 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 1A 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 1A 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.

  • MemberAuthorBook

  • MemberAuthorBookTitle

  • MemberAuthorBookSerial Number.Condition.Date Purchased.Title

  • MemberTitleAuthorBookBorrowsOn loanWritesWrittenbyEACH

  • MemberTitleAuthorBookBorrowsOn loanWritesWrittenbyRESERVESBARREDFINE

  • MemberTitleAuthorBookBorrowsOn loanWritesWrittenbyReservesReservedByFine

  • MemberTitleAuthorBookBorrowsOn loanWritesWrittenbyReservesReservedByFineHasHasResults inImposed onHasForER Diagram One

  • MemberTitleAuthorBookFineReserveER Diagram TwoT_AM_B

  • MemberTitleAuthorBookFineReserveT_AM_BIdentify KeysM#B#T#A#F#

  • MemberTitleAuthorBookFineForeign KeysT_ABorrowM#B#T#A#F#M#,T#M#,B#T#,A#T#M#,B#ER Diagram Two

  • Example Problem 2A 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.

  • DepartmentCompanyEmploymentNoteEmployeeBelongs toOperatesDependentEmploysWorks forHasBelongs toHasBelongs to

  • Example Problem 3A 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.

  • TeacherSchoolChildEmployed byEmploysTeachesTaught byManagesManaged byAttended byAttends

    *