+ All Categories
Home > Documents > Entity-Relationship Model

Entity-Relationship Model

Date post: 24-Jan-2016
Category:
Upload: una
View: 27 times
Download: 0 times
Share this document with a friend
Description:
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 - PowerPoint PPT Presentation
Popular Tags:
14
Entity- Entity- Relationship Model Relationship Model
Transcript
Page 1: Entity-Relationship Model

Entity-Relationship Entity-Relationship ModelModel

Page 2: Entity-Relationship Model

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

Page 3: Entity-Relationship Model

NotationNotation EntityEntity

– A general entity is a component of the database.A general entity 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 publisher; of a publisher; name, addressname, address of a of a customercustomer

NotationNotation– 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)

Page 4: Entity-Relationship Model

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 one field whose values are Identify one field whose values are unique; i.e., as a primary key.unique; i.e., as a primary key.– E.g., E.g., auIDauID in Authors, in Authors, pubIDpubID in in

PublishersPublishers 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)

Page 5: Entity-Relationship Model

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?

Page 6: Entity-Relationship Model

Students, Classes, InstructorsStudents, Classes, Instructors

Students

Instructors

ClassesAttends

Teaches

N N

1

N

Page 7: Entity-Relationship Model

Students with AttributesStudents with Attributes

Students ClassesAttends

Teaches

N N

N

stdName

stdAddress clTime

clName clRoom

instName

stdEmail

Page 8: Entity-Relationship Model

Entity-Relationship DiagramEntity-Relationship Diagram

Page 9: Entity-Relationship Model

Entity-Relationship DiagramEntity-Relationship Diagram

Page 10: Entity-Relationship Model

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

Page 11: Entity-Relationship Model

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, , rmIDrmID, ,

instID) instID)

Underlined and italicized fields are Underlined and italicized fields are foreign keys.foreign keys.

Page 12: Entity-Relationship Model

More TablesMore Tables

Students

Instructors

ClassesAttends

Teaches

N N

1

N

Rooms

Courses

Taught asHolds?

?

? ?

?

Page 13: Entity-Relationship Model

Your TurnYour Turn

BankBank database database– What kind of entities are involved?What kind of entities are involved?– What are some of their attributes?What are some of their attributes?

AcademicAcademic database database– What kind of entities are involved?What kind of entities are involved?– What are some of their attributes?What are some of their attributes?

Page 14: Entity-Relationship Model

Your Turn (2)Your Turn (2)

AirlineAirline database database– What kind of entities are involved?What kind of entities are involved?– What are some of their attributes?What are some of their attributes?

Student GradesStudent Grades database database– What kind of entities are involved?What kind of entities are involved?– What are some of their attributes?What are some of their attributes?


Recommended