Entity-Relationship Model
-
Upload
jared-mckinney -
Category
Documents
-
view
19 -
download
2
description
Transcript of Entity-Relationship Model
Entity-Relationship Entity-Relationship ModelModel
Entity-Relationship ModeEntity-Relationship Mode
What is it?What is it?– Technique for developing an informal Technique for developing an informal
organization of tablesorganization of tables How does it work?How does it work?
– Identify entities (which become tables)Identify entities (which become tables)– Identify attributes of each entity (which Identify attributes of each entity (which
become fields)become fields)– Identify relationshipsIdentify relationships
NotationNotation EntityEntity
– A general object is a component of the database.A general object is a component of the database.– E.g., book, E.g., book, authorauthor, , publisherpublisher, , customercustomer
AttributeAttribute– Property of an entityProperty of an entity– E.g., E.g., titletitle and and priceprice of a book, of a book, namename, , phone phone
numbernumber of a publishers, of a publishers, name, addressname, address of a of a customercustomer
Entity ClassEntity Class– An entity and its attributesAn entity and its attributes– E.g., E.g.,
Books(ISBN, bkTitle, price)Books(ISBN, bkTitle, price)Authors (auID, auName, auPhone)Authors (auID, auName, auPhone)Publishers (pubID, pubName, pubPhone)Publishers (pubID, pubName, pubPhone)
Purpose of AttributesPurpose of Attributes Contain raw data for the databaseContain raw data for the database
– E.g., E.g., bkTtitlebkTtitle, , priceprice in Books, auName in in Books, auName in AuthorsAuthors
Identify a record uniquely, i.e., as a Identify a record uniquely, i.e., as a primary key.primary key.– E.g., E.g., auIDauID in Authors, in Authors, pubIDpubID in Publishers in Publishers
Link a table to another table, i.e., as Link a table to another table, i.e., as a foreign key. (Need not be included a foreign key. (Need not be included in the Entity-relationship diagram)in the Entity-relationship diagram)
Entity-Relationship DiagramEntity-Relationship Diagram
Given the following entities:Given the following entities:– Students (stdID, stdName, stdAddress)Students (stdID, stdName, stdAddress)– Classes (clID, clName, clTime, clRoom, Classes (clID, clName, clTime, clRoom,
instructor)instructor)– Instructors (instID, instName, instGender)Instructors (instID, instName, instGender)
How are they related?How are they related?
Students, Classes, InstructorsStudents, Classes, Instructors
Students
Instructors
ClassesAttends
Teaches
N N
1
N
Students with AttributesStudents with Attributes
Students ClassesAttends
Teaches
N N
N
stdName
stdAddress clTime
clName clRoom
instName
Entity-Relationship DiagramEntity-Relationship Diagram
Entity-Relationship DiagramEntity-Relationship Diagram
Refining TablesRefining Tables
RecallRecall– Classes (clID, clName, clTime, clRoom,Classes (clID, clName, clTime, clRoom,
instName) instName) Several classes may have the same name. Several classes may have the same name.
E.g. EN201-01, EN201-02 are both named E.g. EN201-01, EN201-02 are both named “Intro to Writing.”“Intro to Writing.”
Rooms may require more information.Rooms may require more information. Instructor name is already in Instructor Instructor name is already in Instructor
tabletable
Create New TablesCreate New Tables
Courses(crsID, crsName, crsCredits)Courses(crsID, crsName, crsCredits) Rooms(rmID, rmLocation,Rooms(rmID, rmLocation,
rmNumber, rmCapacity) rmNumber, rmCapacity) Classes(clID, classTime, Classes(clID, classTime, crsIDcrsID, rmID, , rmID,
instID) instID)
Underlined and italicized fields are Underlined and italicized fields are foreign keys.foreign keys.
More TablesMore Tables
Students
Instructors
ClassesAttends
Teaches
N N
1
N
Rooms
Courses
Taught asHolds
Your TurnYour Turn
BankBank database database– What kind of entities are involve?What kind of entities are involve?– What are some of their attributes?What are some of their attributes?
AcademicAcademic database database– What kind of entities are involve?What kind of entities are involve?– What are some of their attributes?What are some of their attributes?
Your Turn (2)Your Turn (2)
AirlineAirline database database– What kind of entities are involve?What kind of entities are involve?– What are some of their attributes?What are some of their attributes?
Student GradesStudent Grades database database– What kind of entities are involve?What kind of entities are involve?– What are some of their attributes?What are some of their attributes?
Establish Links-CardinalityEstablish Links-Cardinality
Books Customers
Authors EmployeesPublishers
Library
Establish Links-CardinalityEstablish Links-Cardinality
Student BuildingsRooms
Classes FacultyCourses Dorms
Academics
Establish Links-CardinalityEstablish Links-Cardinality
Aircrafts FlightsReservations
Customers FltAttendantsPilots
Airlines