Presentation is loading. Please wait.

Presentation is loading. Please wait.

INF1343, Week 4 Database Design and ER Modeling This presentation is licensed under Creative Commons Attribution License, v To view a copy of this.

Similar presentations


Presentation on theme: "INF1343, Week 4 Database Design and ER Modeling This presentation is licensed under Creative Commons Attribution License, v To view a copy of this."— Presentation transcript:

1 INF1343, Week 4 Database Design and ER Modeling This presentation is licensed under Creative Commons Attribution License, v. 3.0. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/. This presentation incorporates images from the Crystal Clear icon collection by Everaldo Coelho, available under LGPL from http://everaldo.com/crystal/. Yuri Takhteyev University of Toronto January 24, 2010

2 Announcements 1.Assignment 1 due now. Submit late assignments via email as PDF. 2. Assignment 2 to be posted today. (Due in 3 weeks. Start early.) 3. No office hours today.

3 Schedule Intro SQL Design Interfacin g Etc.

4 +--------------------+ | Tables_in_diveshop | +--------------------+ | BIOLIFE | | BIOSITE | | DEST | | DIVECUST | | DIVEITEM | | DIVEORDS | | DIVESTOK | | SHIPVIA | | SHIPWRCK | | SITES | +--------------------+

5 1. Serves the purpose. 2. Simplifies updates. 3. Avoids “anomalies”. Good DB Design

6 Two Approaches 1. Start with whatever, then fix it 2. Start by modeling ER Modeling

7 Database Design requirements analysis implementation deployment design

8 clientyoudatabaseusers the problem functional specification clarification a design a schema use feedback a new problem

9 Functional Specifications What is the system going to do? (Not how, but what.)

10 Course Enrollment What do we want from a course enrollment system?

11 “Use Cases” A student wants to enroll in a course for the next semester. The student goes to the website for the enrollment system and logs in. The student is presented with a list of courses there he or she is enrolled in. There is a button next to each course to un-enroll from it. There is also a search box that the student can use use to look for courses that they are not enrolled in. The student can find the course by the course code or course title...

12 ER Model E is for “Entities” R is for “Relationships” (“relationships” != “relations”)

13 “Use Cases” A student wants to enroll in a course for the next semester. The student goes to the website for the enrollment system and logs in. The student is presented with a list of courses there he or she is enrolled in. There is a button next to each course to un-enroll from it. There is also a search box that the student can use use to look for courses that they are not enrolled in. The student can find the course by the course code or course title...

14 Entities The “things” we need to keep track of in our database: students courses instructors rooms time slots

15 student last name first name utorid date of birth attributes programcoursepayment other entities

16 student last name first name utorid date of birth programcoursepayment other entities a date up to 8 letters or numbers what alphabet? phone number Local? Domestic? “domains”

17 student last name first name utorid date of birth “Chen’s notation”

18 student ---------------------------------------------------------------------------------- last name first name utorid date of birth “UML notation” (simplified)

19 program ----------------------------------------------------------------------------------... course ----------------------------------------------------------------------------------... payment ----------------------------------------------------------------------------------... student ---------------------------------------------------------------------------------- last name first name utorid date of birth

20 program ---------------------------------------------------------------------------------- name code course ---------------------------------------------------------------------------------- code title payment ---------------------------------------------------------------------------------- amount date session ---------------------------------------------------------------------------------- code start date student is in a program student made a payment student enrolls in a course course is offered in a session student ---------------------------------------------------------------------------------- last name first name utorid date of birth course belongs to a program

21 A Movie Database What are the entities? Which are related?

22

23 Cardinality student ---------------------------------------------------------------------------------- last name first name utorid date of birth payment ---------------------------------------------------------------------------------- amount date payment ---------------------------------------------------------------------------------- amount date payment ---------------------------------------------------------------------------------- amount date payment ---------------------------------------------------------------------------------- amount date payment ---------------------------------------------------------------------------------- amount date one student, many payments “one-to-many” relationship

24 student ---------------------------------------------------------------------------------- last name first name utorid date of birth payment ---------------------------------------------------------------------------------- amount date “Crow’s Foot Notation”

25 not more than 1many “Crow’s Foot Notation”

26

27 at least 1 (mandatory) could be 0 (optional) “Crow’s Foot Notation” 1..10..N

28 just one zero or many “UML Notation” 1..1 or just “1” 0..N or “0..*” 1..10..N

29 at least 1 (mandatory) “Weak Entity” a weak entity studentpayment

30 More Examples worldcharacter speciespet courseassignment ???

31 Variations ownerpet manageremployee ???

32 Questions on 1:M?

33 WeWe ❤ 1:M Because they are really easy to represent in a relational database.

34 Many-to-Many student ---------------------------------------------------------------------------------- last name first name utorid date of birth course ---------------------------------------------------------------------------------- code title

35 Examples bookauthor personaddress courseinstructor ???

36 Movie Database Which relationships are 1:M and which are M:M?

37 We ! ❤ M:M Because they cannot be represented in a relational database.

38 Breaking Up M:M student ---------------------------------------------------------------------------------- last name first name utorid date of birth course ---------------------------------------------------------------------------------- code title

39 “Associative Entity” student ---------------------------------------------------------------------------------- last name first name utorid date of birth course ---------------------------------------------------------------------------------- code title enroll ment

40 Examples book author author ship ??? person address reside nce

41 Questions on M:M?

42 One-to-One ???

43 One-to-One ???

44 One-to-One enginecar the engine is installed in the car engines in stock cars shipped

45 Examples citymayor captainship chef signature dish ???

46 Recursive Relationships person likes

47 Recursive Relationships person likes

48 Examples employee tax return coin image ??? is filed jointly with supervises is the flip side of ???

49 N-nary Relationships seller sold (what?) to the buyer sellerbuyer house seller sold house (to whom?) buyer bought house (from whom?)

50 N-nary Relationships seller buys a house from buyer sellerbuyer house

51 N-nary Relationships seller house buyer sale

52 Putting It Together ● OpenOffice Draw – Free / open source – Available in the lab – You can get “Crow’s Foot” templates at http://www.thinktek.ca/articles/article2.php – Alternatively, do UML notation (“n..m”) by hand ● Microsoft Visio ● Your favorite software Options for software:

53 Questions?

54


Download ppt "INF1343, Week 4 Database Design and ER Modeling This presentation is licensed under Creative Commons Attribution License, v To view a copy of this."

Similar presentations


Ads by Google