1 / 9

Summary on Translating ER Diagra ms

Summary on Translating ER Diagra ms. A may not do B No minimum requirement A should do B at least once Minimum requirement: 1 A can do B many times No upper limit A can do B at most once Upper limit: 1 A does B exactly once A does B 1 or more times A does B 0, 1, or more times

gilles
Download Presentation

Summary on Translating ER Diagra ms

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. Summary onTranslating ER Diagrams

  2. A may not do B • No minimum requirement • A should do B at least once • Minimum requirement: 1 • A can do B many times • No upper limit • A can do B at most once • Upper limit: 1 • A does B exactly once • A does B 1 or more times • A does B 0, 1, or more times • A does B 0 or 1 times Does B A Does B A Does B A Does B A Does B A Does B A

  3. To judge if an entity B is a weak entity • First, the relationship must have the following two constraints: • Second, B’s key (bid) alone cannot serve as a primary key for the entity set B, e.g., • payment-number (of loan) • section-number (of course) • dependent-name (of employee) bid aid Does B A

  4. Many to Many • Create three tables • A (primary key: (aid)) • B (primary key: (bid)) • Does (primary key: (aid, bid); foreign key: (aid), (bid)) • Same, but the total participation constraint of A is not captured • Same, but the total participation constraint of B is not captured • Same, but both total participation constraints are not captured bid aid Does B A bid aid Does B A bid aid Does B A bid aid Does B A

  5. bid • One to Many • Create two tables (tables B and Does combined into Does_B) • A (primary key: (aid)) • Does_B (primary key:(bid); foreign key:(aid)) • Same, but the total participation constraint of A is not captured • Same, also in Does_B: aid … NOT NULL • Same, also in Does_B: aid … NOT NULLthe total participation constraint of A is not captured aid Does B A bid aid Does B A bid aid Does B A bid aid Does B A

  6. bid aid • One to One • Create two tables • A (primary key: (aid)) • Does_B (primary key: (bid); foreign key: (aid);unique: (aid)) • Or, • A_Does (primary key: aid; foreign key: (bid);unique: (bid)) • B (primary key: (bid)) Does B A

  7. bid aid • One to One (cont.) • Create two tables • A (primary key: (aid)) • Does_B (primary key: (bid); foreign key: (aid);unique: (aid);aid … NOT NULL) • A_Does (primary key: (aid); foreign key: (bid);unique: (bid);bid … NOT NULL) • B (primary key: (bid)) Does B A bid aid Does B A

  8. One to One (cont.) • Create two tables • A_Does_B (primary key: (aid); unique: (bid);bid … NOT NULL) bid aid Does B A Combine into a single table. This is suggested by a student in the class!!!

  9. Weak Entity • Create two tables • A (primary key: aid) • Does_B (primary key: (aid, bid); foreign key: (aid);aid … NOT NULL;ON DELETE CASCADE) bid aid Does B A This is optional since primary key already implies aid must be NOT NULL.

More Related