Presentation is loading. Please wait.

Presentation is loading. Please wait.

DATA MODELING AND ENTITY-RELATIONSHIP MODEL II IST 210: Organization of Data IST210 1.

Similar presentations


Presentation on theme: "DATA MODELING AND ENTITY-RELATIONSHIP MODEL II IST 210: Organization of Data IST210 1."— Presentation transcript:

1 DATA MODELING AND ENTITY-RELATIONSHIP MODEL II IST 210: Organization of Data IST210 1

2 Developing an E-R Diagram: Outline 1. Draw Entities Define Attributes Define Identifier 2. Define the relationships Maximum cardinality: One or Many (1:1, 1:N, N:M) Minimum cardinality: Mandatory or Optional 3. Verify and refine IST210 2

3 Entity-Relationship Diagram IST210 3 UserID Video ID Name Address Email USER VIDEO Title Description Length Entity Name  Attributes  Identifier  Minimum cardinality MandatoryOptional Maximum cardinality OneMany

4 Maximum Cardinality: Exercise IST210 4 BUILDINGAPARTMENT BUILDINGAPARTMENT BUILDINGAPARTMENT BUILDINGAPARTMENT Which design is most suitable? (A) (B) (C) (D) has OneMany

5 Minimum Cardinality: Exercise IST210 5 BUILDINGAPARTMENT BUILDINGAPARTMENT BUILDINGAPARTMENT BUILDINGAPARTMENT Which design is most suitable? (A) (B) (C) (D) has MandatoryOptional

6 LISA’S BOOKSTORE Case study IST210 6

7 Case Study: Lisa’s Bookstore (1) IST210 7 You are helping Lisa maintain information of her bookstore. A book contains information about book title, publisher, author names, and publication year. For a publisher, store the information about name, location, phone number. An author’s name and country should be stored in the database.

8 IST210 8 Draw Entities

9 IST210 9 BOOKID Title Year Publisher AuthorID Name Country PublisherName Location Phone BOOK AUTHOR PUBLISHER Draw Entities

10 IST210 10 BOOKID Title Year Publisher AuthorID Name Country PublisherName Location Phone BOOK AUTHOR PUBLISHER Publisher and Author should NOT be the attributes of the book! Information of publisher and author for a book is captured by the relationships! Draw Entities

11 Attribute v.s. Foreign Key Please note that there is NO foreign key concept in E-R diagram. Do not make a foreign key as an attribute in the E-R diagram. For example, PublisherName should NOT be an attribute of the BOOK entity. Their relationship is currently represented by the line and the corresponding min/max cardinality. In Chapter 5, we will learn how to transform a E-R diagram to tables. At that point, some relationships might be transformed into foreign key. IST210 11

12 IST210 12 BOOKID Title Year AuthorID Name Country PublisherName Location Phone BOOK AUTHOR PUBLISHER Maximum cardinality

13 IST210 13 BOOKID Title Year AuthorID Name Country PublisherName Location Phone BOOK AUTHOR PUBLISHER Maximum cardinality

14 IST210 14 BOOKID Title Year AuthorID Name Country PublisherName Location Phone BOOK AUTHOR PUBLISHER Minimum cardinality

15 IST210 15 BOOKID Title Year AuthorID Name Country PublisherName Location Phone BOOK AUTHOR PUBLISHER Minimum cardinality

16 Case Study: Lisa Bookstore (2) IST210 16 A customer can be uniquely identified using his/her email address. A customer has information about his/her name, phone number and home address. Lisa wants to track all the book purchases. Each purchase is made by one customer on one book. The price and date of the purchase will be stored in database. A customer may purchase many books or not purchase any book.

17 IST210 17 BOOKID Title Year AuthorID Name Country PublisherName Location Phone BOOK AUTHOR PUBLISHER Add New Entities

18 IST210 18 BOOKID Title Year BOOK PurchaseID Price Date PURCHASE AuthorID Name Country AUTHOR EmailAddress Name Address Phone CUSTOMER PublisherName Location Phone PUBLISHER Minimum cardinality Maximum cardinality

19 IST210 19

20 IST210 20 BOOKID Title Year BOOK AuthorID Name Country PublisherNam e Location Phone AUTHOR PUBLISHER EmailAddress Name Address Phone CUSTOMER PurchaseID Price Date PURCHASE

21 Case Study: Lisa Bookstore (3) IST210 21 In Lisa’s bookstore, there are some events organized to interact with the customers. Lisa wants to record the information of events, including event name, type, and date. She also wants to record which customers attend which events.

22 IST210 22 BOOKID Title Year BOOK AuthorID Name Country AUTHOR EventID Name Date Type EVENT EmailAddress Name Address Phone CUSTOMER PurchaseID Price Date PURCHASE PublisherName Location Phone PUBLISHER Minimum cardinality Maximum cardinality

23 IST210 23

24 IST210 24 BOOKID Title Year BOOK AuthorID Name Country AUTHOR EventID Name Date Type EVENT Complete E-R Diagram PurchaseID Price Date PURCHASE EmailAddress Name Address Phone CUSTOMER PublisherName Location Phone PUBLISHER

25 COURSE REGISTRATION SYSTEM Case study IST210 25

26 Case Study: Course Registration (1) IST210 26 You are helping Penn State create a course registration system. Store information about all students, including their student IDs, names, emails, and their major departments (assuming student has at most one major department). The department should have information about department name, building name, and phone number.

27 IST210 27 Draw Entities

28 IST210 28 StudentID Name Email STUDENT DepartName Building Phone DEPARTMENT Minimum cardinality Maximum cardinality

29 IST210 29 StudentID Name Email STUDENT DepartName Building Phone DEPARTMENT

30 Case Study: Course Registration (2) IST210 30 A course should have information about course ID, course name, and instructor name. Students can take many courses and a course can be registered by many students. We also need to store the final grade for a student in a course.

31 IST210 31 StudentID Name Email STUDENT DepartName Building Phone DEPARTMENT CourseID CourseName Instructor COURSE Where should we put grade???

32 Attributes on Relationships? When you need to store some information about a relationship, the relationship should actually be designed as an entity. If we want to store the grades for the relationship between COURSE and STUDENT, we need to make GRADE as a separate entity. If we only want to store which student taking which course, we don’t need a separate entity to capture their relationship. IST210 32

33 IST210 33 StudentID Name Email STUDENT StudentID CourseID Grade GRADE DepartName Building Phone DEPARTMENT CourseID CourseName Instructor COURSE Minimum cardinality Maximum cardinality

34 IST210 34

35 IST210 35 StudentID Name Email STUDENT StudentID CourseID Grade GRADE DepartName Building Phone DEPARTMENT CourseID CourseName Instructor COURSE

36 Case Study: Course Registration (3) IST210 36 A course is offered by a department. We also want to store this information.

37 IST210 37

38 IST210 38 StudentID Name Email STUDENT StudentID CourseID Grade GRADE DepartName Building Phone DEPARTMENT Complete E-R Diagram CourseID CourseName Instructor COURSE

39 IST210 39 Reminder Next Thursday (Oct 21 st ) is a big day: Assignment 4 Due Report 2 Due


Download ppt "DATA MODELING AND ENTITY-RELATIONSHIP MODEL II IST 210: Organization of Data IST210 1."

Similar presentations


Ads by Google