1 / 13

A library has many items

A library has many items. Item. Library. 1:M. An item is categorized by the type. Types. Item. 1:M. For each type, there is a series of “other” classifications. This library is only interested in genre and subject. Genre. Genre. Genre. Genre. Genre. Genre. Type. 1:M. Subject.

mdillion
Download Presentation

A library has many items

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A library has many items Item Library 1:M

  2. An item is categorized by the type. Types Item 1:M

  3. For each type, there is a series of “other” classifications. This library is only interested in genre and subject. Genre Genre Genre Genre Genre Genre Type 1:M Subject Subject Subject Subject Subject 1:M 1:M 1:M

  4. Each item may be removed by a library subscriber. Subscriber Subscriber Subscriber Item Item 1:M

  5. A subscriber is a person. A subscriber may remove between 1 and 5 specific items. Subscriber Item 1:M

  6. Now put it all together Subject 1:M 1:M Library 1:M Types Item 1:M Genre M:N EntitiesLibraryItem Types SubjectGenresSubscriber Subscriber

  7. Primary Keys • Library – Library Code • Item – Call number • Genre – Genre Code • Subject – Subject Code • Subscriber – Subscriber ID

  8. Foreign Keys Library—none Item—Library Code, Type Code, Subject Code, Subscriber Code Type – none Subject – none Subscriber—Call Number

  9. How to build • If you look at the diagram, you see one of the entities has a M:N (many to many) relationship. You can’t build this type, so you need to break it into two separate relationships and introduce another entity….

  10. How to build M:N • So you need to add a bridge entity. • We will call that entity Check Out. • The Primary Key (PK) for Check Out will be the PK from ITEM and the PK from Subscriber but together. Check Out PK is 2 entities…. • When I look at the attributes for the PK individually, I see that makes 2 foreign keys for Check Out • One that points back to the Item and one that points back to the Subscriber…. • This is how you build a M:N (many to many) relationship.

  11. Updated diagram Subject 1:M 1:M Library 1:M Types Item 1:M Genre EntitiesLibraryItem Types SubjectGenresSubscriber Check OUT 1:M Check OUT 1:M Subscriber

  12. Updated Primary Keys • Library – Library Code • Item – Call number • Genre – Genre Code • Subject – Subject Code • Subscriber – Subscriber ID • Check Out – Call Number, Subscriber ID

  13. Updated Foreign Keys Library—none Item—Library Code, Type Code, Subject Code, None Type – none Subject – none Subscriber--None Check Out – Call Number, Subscriber ID Note that the changes in the Item and Subscriber entities.

More Related