1 / 14

Entity-Relationship Model

Entity-Relationship Model. Entity-Relationship Mode. What is it? Technique for developing an informal organization of tables How does it work? Identify entities (which become tables) Identify attributes of each entity (which become fields) Identify relationships. Notation. Entity

una
Download Presentation

Entity-Relationship Model

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. Entity-Relationship Model

  2. Entity-Relationship Mode • What is it? • Technique for developing an informal organization of tables • How does it work? • Identify entities (which become tables) • Identify attributes of each entity (which become fields) • Identify relationships

  3. Notation • Entity • A general entity is a component of the database. • E.g., book, author, publisher, customer • Attribute • Property of an entity • E.g., title and price of a book; name, phone number of a publisher; name, address of a customer • Notation • An entity and its attributes • E.g., Books(ISBN, bkTitle, price)Authors (auID, auName, auPhone)Publishers (pubID, pubName, pubPhone)

  4. Purpose of Attributes • Contain raw data for the database • E.g., bkTtitle, price in Books, auName in Authors • Identify one field whose values are unique; i.e., as a primary key. • E.g., auID in Authors, pubID in Publishers • Link a table to another table, i.e., as a foreign key. (Need not be included in the Entity-relationship diagram)

  5. Entity-Relationship Diagram • Given the following entities: • Students (stdID, stdName, stdAddress) • Classes (clID, clName, clTime, clRoom, instructor) • Instructors (instID, instName, instGender) • How are they related?

  6. Students, Classes, Instructors N Attends N Students Classes N Teaches 1 Instructors

  7. Students with Attributes instName stdAddress clTime stdName stdEmail clName clRoom N Attends N Students Classes N Teaches

  8. Entity-Relationship Diagram

  9. Entity-Relationship Diagram

  10. Refining Tables • Recall • Classes (clID, clName, clTime, clRoom, instName) • Several classes may have the same name. E.g. EN201-01, EN201-02 are both named “Intro to Writing.” • Rooms may require more information. • Instructor name is already in Instructor table

  11. Create New Tables • Courses(crsID, crsName, crsCredits) • Rooms(rmID, rmLocation, rmNumber, rmCapacity) • Classes(clID, classTime, crsID, rmID, instID)Underlined and italicized fields are foreign keys.

  12. More Tables Courses ? ? Taught as Holds Rooms ? ? ? Attends Classes Students N N N Teaches 1 Instructors

  13. Your Turn • Bank database • What kind of entities are involved? • What are some of their attributes? • Academic database • What kind of entities are involved? • What are some of their attributes?

  14. Your Turn (2) • Airline database • What kind of entities are involved? • What are some of their attributes? • Student Grades database • What kind of entities are involved? • What are some of their attributes?

More Related