Presentation is loading. Please wait.

Presentation is loading. Please wait.

Entity-Relationship Model. Entity-Relationship Mode What is it? What is it? –Technique for developing an informal organization of tables How does it work?

Similar presentations


Presentation on theme: "Entity-Relationship Model. Entity-Relationship Mode What is it? What is it? –Technique for developing an informal organization of tables How does it work?"— Presentation transcript:

1 Entity-Relationship Model

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

3 Notation Entity Entity –A general entity is a component of the database. –E.g., book, author, publisher, customer Attribute 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 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 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. 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) 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: Given the following entities: –Students (stdID, stdName, stdAddress) –Classes (clID, clName, clTime, clRoom, instructor) –Instructors (instID, instName, instGender) How are they related? How are they related?

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

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

8 Entity-Relationship Diagram

9

10 Refining Tables Recall 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.” Several classes may have the same name. E.g. EN201-01, EN201-02 are both named “Intro to Writing.” Rooms may require more information. Rooms may require more information. Instructor name is already in Instructor table Instructor name is already in Instructor table

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

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

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

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


Download ppt "Entity-Relationship Model. Entity-Relationship Mode What is it? What is it? –Technique for developing an informal organization of tables How does it work?"

Similar presentations


Ads by Google