Presentation is loading. Please wait.

Presentation is loading. Please wait.

University of Milano Bicocca, Italy Carlo Batini

Similar presentations


Presentation on theme: "University of Milano Bicocca, Italy Carlo Batini"— Presentation transcript:

1 University of Milano Bicocca, Italy Carlo Batini
Course in Data Base Design The Entity Relationship model

2 © Carlo Batini, 2015 This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. To view a copy of this license, visit

3 High Level Conceptual Map

4 Low Level Conceptual Map

5 Conceptual Design and Logical Design
Conceptual schema Logical design Logical schema Relational model Conceptual design Requirements Entity Relationship Model

6 Diagrammatic representation of the ER Model
Construct of the ER model Diagrammatic representation Entity Attribute of entity Relationship Attribute of relationship Is-a hierarchy Generalization hierarchy Identifier

7 A set of pictures

8 Four student instances and the Entity Student

9 A class with a professor and 20 students

10 Entity and Attribute of Entity

11 An example of entity Student

12 Entity Student Student Id = 25 Student Id = 34 Surname = Smith
Surname = Wang Student Id = 49 Surname = Xu

13 Question 2.1 20 students Batini

14 Entity and its instances
Student Student ID Surname Place of Birth <41, Rossi, Milan> <37, Batini, Rome> <53, Wang, Harbin>

15 Entity and its attributes
Student ID Student Surname Place of Birth Student2 <Id = 41, Surname = Rossi, Place of Birth = Milan> <Id = 53, Surname = Wang, Place of Birth = Harbin> <Id = 37, Surname = Batini, Place of Birth = Rome>

16 Entity and its attributes
Student1 <Id = 41, Surname = Rossi, Place of Birth = Milan, Year of Birth = 1990> Student 2 <Id = 37, Surname = Wang, Place of Birth = Harbin, Year of Birth = 1993> Student 3 <Id = 53, Surname = Batini, Place of Birth = Rome, Year of Birth = 1987>

17 Entity and its attributes
Student Student ID Surname Place of Birth Year of Birth

18 Entity and its attributes
Student Student ID Surname Place of Birth Student1 <Id = 41, Surname = Rossi, Place of Birth = Milan, Year of Birth = 1990> Student 3 <Id = 53, Surname = Batini, Place of Birth = Rome, Year of Birth = 1987> Student 2 <Id = 37, Surname = Wang, Place of Birth = Harbin, Year of Birth = 1993> Year of Birth

19 Cardinalities of attributres
Student ID Student Surname Telephone Number Student Student ID Surname Telephone Number (1,n) Student Student ID Surname Telephone Number (0,n)

20 Exercise 2.3 Full Associate Professor First Name Last Name
Date of Birth Associate

21 Relationship and Attributes of Relationships

22 Motivating example

23 From instances to relationships
Student ID Student Surname Course ID Course Course Name <12, Wang> S2 C1 <3, Algorithms> S1 <13, Batini> C2 <7, Databases> S3 <32, Xu> Notice that e.g. <12, Wang> is shorthand for <Student Id = 12, Surname = Wang>

24 From instances to relationships
Student ID Student <13, Batini> <32, Xu> S1 S2 S3 C1 C2 <7, Databases> <3, Algorithms> <12, Wang> Notice that e.g. <12, Wang> is shorthand for <Student Id = 12, Surname = Wang> Surname Course Course ID Course Name

25 From instances to relationships
< Student Id = 12, Surname = Wang> S2 C1 < Course Id = 3, Course Name = ?? > S1 < Student Id = 13, Surname = ??> C2 < Course Id = 7, Course Id = Databases> S3 < Student Id = 32, Surname = Xu >

26 From instances to relationships
<13, Batini> <32, Xu> S1 S2 S3 C1 C2 <7, Databases> <3, Algorithms> <21, Wang>

27 From instances to relationships
Student Student ID Surname Course Course ID Course Name <13, Batini> <32, Xu> S1 S2 S3 C1 C2 <7, Databases> <3, Algorithms> <21, Wang>

28 From instances to relationships
Student ID Student Surname <13, Batini> <32, Xu> S1 S2 S3 C1 C2 <7, Databases> <3, Algorithms> <21, Wang> Exam Course Course ID Course Name

29 Attributes of Relationships
Student ID Student Surname <21, Wang> S2 C1 <3, Algorithms> <80> S1 <13, Batini> Exam <70> C2 <7, Databases> S3 <32, Xu> <60> Course Course ID Course Name

30 Attributes of relationships
Student ID Student Surname <21, Wang> C1 <3, Algorithms> 95 Exam <13, Batini> 90 C2 <7, Databases> 80 Course Course ID Course Name <32, Xu>

31 Attributes of relationships
Student ID Student Surname <21, Wang> C1 <3, Algorithms> 95 Exam Grade <13, Batini> 90 C2 <7, Databases> 80 Course Course ID Course Name <32, Xu>

32

33 Specific types of relationships

34 Entites with two relationships in common
Student Student ID Surname Course Enrolled Course ID Course Name <13, Batini> <32, Xu> S1 S2 S3 C1 C2 <7, Databases> <3, Algorithms> <21, Wang> C3 <5, Algebra>

35 Entites with two relationships in common
<13, Batini> <32, Xu> S1 S2 S3 C1 C2 <7, Databases> <3, Algorithms> <21, Wang> C3 <5, Algebra> Student Student ID Surname Course Enrolled Course ID Course Name

36 Entites with two relationships in common
<13, Batini> <32, Xu> S1 S2 S3 C1 C2 <7, Databases> <3, Algorithms> <21, Wang> C3 <5, Algebra> Student Student ID Surname Course Enrolled Course ID Course Name

37 Entites with two relationships in common
<13, Batini> <32, Xu> S1 S2 S3 C1 C2 <7, Databases> <3, Algorithms> <21, Wang> C3 <5, Algebra> Student Student ID Surname Course Enrolled Course ID Course Name Exam Grade 90 80

38 Entites with two relationships in common
Student Student ID Surname Course Enrolled Course ID Course Name Exam Grade <13, Batini> <32, Xu> S1 S2 S3 C1 C2 <7, Databases> <3, Algorithms> <21, Wang> C3 <5, Algebra>

39 Ternary relationship Supplier Department Product Supplier ID
Supplier Name Address Product ID Name Price Department ID

40 Ternary relationship Supplier Department Product Product ID
Product Name Price Department made of Product Supplier Supplier ID Supplier Name Address (1,n) Product ID Name Price Quantity Department ID

41 Recursive relationship
Part Part ID Price made of Product Part Name Part ID Part Part Name Price superpart subpart made of

42 Exercise 2.2

43 Exercise 2.1 Design a conceptual schema for the following requirements: Professors have an Id and an Age. Professors work in Universities, and Universities are located in Cities. Universities have a name and a Dean. Cities have a name and a Region in which they are located.

44 Choose entities Professors have an Id and an Age. Professors work in Universities, and Universities are located in Cities. Universities have a name and a Dean. Cities have a name and a Region in which they are located.

45 Solution Professor University City

46 Choose attributes of entities
Professors have a fiscal code and an Age. Professors work in Universities, and Universities are located in Cities. Universities have a name and a Dean. Cities have a name and a Region in which they are located.

47 Solution University City Professor Professor Id Dean Date of Birth
Name Region University Dean City Professor Id Date of Birth Professor

48 Choose relationships Professors have a fiscal code and an Age. Professors work in Universities, and Universities are located in Cities. Universities have a name and a Dean. Cities have a name and a Region in which they are located.

49 Solution University Professor in City Professor Id Date of Birth Name
Dean University in Name City Region

50 Solution Professor University Works in in City Professor Id Name Dean
Date of Birth Professor Name Dean University Works in in Name Region City

51 Choose attributes of relationships
Professors have a fiscal code and an Age. Professors work in Universities, and Universities are located in Cities. Universities have a name and a Dean. Cities have a name and a Region in which they are located.

52 Solution Professor University Works in in City Professor Id Name Dean
Date of Birth Professor Name Dean University Works in in Name Region City

53 Solution University Professor in City Professor Id Name Dean
Works in University Dean Worked in the past Professor Id Date of Birth Professor in Region City

54 Solution University Professor in City Professor Id Name Dean
Works in University Dean Worked in the past Year of transfer Professor Id Date of Birth Professor in Region City

55 Is-a Hierarchies and Generalizations

56 Different possible terms for the object in the image
Look at that thing Look at that tree Look at that pine Guardia quel pino romano (o domestico)

57

58 Is-a hierarchy – first example
Batini 20 students

59 Is-a hierarchies Student Foreign S1 FS1 S3 S4 S5 FS2 S2

60 Is-a hierarchies Student Foreign S1 FS1 S3 S4 S5 FS2 S2

61 Is-a hierarchies Student Foreign Student S1 S3 S5 S2 S4 FS1 FS2
Student Id Given Name Surname Foreign Student Country of Birth

62 Is-a hierarchies Student Foreign S1 S3 S5 S2 S4 FS1 FS2 Student Id
Given Name Surname Country of Birth S1 FS1 S3 S4 S5 FS2 S2

63 Generalizations Student Foreign Chinese S2 S5 S1 S3 S4

64 Exercise

65 Exercise Person Student Course City Surname Name Region Born in
Enrolled Course Course Id City

66 Exercise Born in Person Student City Course Enrolled Surname Name
Region Course Id

67 Exercise Person City Born in Student Course Enrolled Surname Name Name
Region Name Person City Born in Student Name Course Id Course Enrolled

68 Exercise Person City Born in Student Course Enrolled Surname Name Name
Region Name Person City Born in Student Name Course Id Course Enrolled

69 Student Foreign St. Chinese St. Course Country City Born many one
Student ID Last Name Student First Name Chinese St. Foreign St. Country Name Continent City Region Enrolled Course Course Id

70 Student Foreign St. Chinese St. Course Country City Born Student ID
Last Name Student First Name Chinese St. Foreign St. Country Name Continent City Region Enrolled Course Course Id

71 Student Course Foreign St. Chinese St. Country City Born many one
Student ID Last Name First Name Chinese St. Foreign St. Country Name Continent City Region Enrolled Course Course Id

72 Student Course Foreign St. Chinese St. Country City Born Student ID
Last Name First Name Chinese St. Foreign St. Country Name Continent City Region Enrolled Course Course Id

73 Exercise 2.2 – first part

74 Exercise 2.2 – first part Students of a University attend courses, and pass them. Courses have a last name, a first name and a year of enrollment. Students have an ID, a Last Name and First Name. Students are born in cities. A course passed by a Student has a mark and a date. Courses are teached by professors. Professors have a last name and a first name. They may be Associate Professors or Full professors, only for Full Professors we are interested to the City of Birth, with name and region. Every professor belongs to a Department. Departments have a Name and an address. Find entities, relationships, attrivbutes of entities, attributes of relationships, Is-a relationships and generalizations.

75 Entities Students of a University attend courses, and pass them. Courses have a last name, a first name and a year of enrollment. Students have an ID, a Last Name and First Name. A course passed by a Student has a mark and a date. Courses are teached by professors. Professors have a last name and a first name. They may be Associate Professors or Full professors, only for Full Professors we are interested to the City of Birth, with name and region. Every professor belongs to a Department. Departments have a Name and an address.

76 Entities Student Course Professor Associate Department Full Professor
City

77 Attributes of entities
Students of a University attend courses, and pass them. Courses have a last name, a first name and a year of enrollment. Students have an ID, a Last Name and First Name. A course passed by a Student has a mark and a date. Courses are teached by professors. Professors have a last name and a first name. They may be Associate Professors or Full professors, only for Full Professors we are interested to the City of Birth, with name and region. Every professor belongs to a Department. Departments have a Name and an address.

78 + Attributes of Entities
ID Last Name Name Student Course Year of Enrollment Professor First Name Associate Department Full Professor Address City Region

79 Generalizations Students of a University attend courses, and pass them. Courses have a last name, a first name and a year of enrollment. Students have an ID, a Last Name and First Name. A course passed by a Student has a mark and a date. Courses are teached by professors. Professors have a last name and a first name. They may be Associate Professors or Full professors, only for Full Professors we are interested to the City of Birth, with name and region. Every professor belongs to a Department. Departments have a Name and an address.

80 + Generalizations Student Course Department City Professor Associate
ID Last Name Name Student Course Year of Enrollment Professor First Name Associate Full Professor Department Address City Region First Name

81 Relationships Students of a University attend courses, and pass them. Courses have a last name, a first name and a year of enrollment. Students have an ID, a Last Name and First Name. A course passed by a Student has a mark and a date. Courses are teached by professors. Professors have a last name and a first name. They may be Associate Professors or Full professors, only for Full Professors we are interested to the City of Birth, with name and region. Every professor belongs to a Department. Departments have a Name and an address.

82 + Relationships Student Course Professor Department City Enrolled in
Passed ID Last Name Name Enrolled in Student Course Year of Enrollment Professor First Name Associate Teach Full Professor Belongs to Born in Department Address City Region

83 Attributes of relationships
Students of a University attend courses, and pass them. Courses have a last name, a first name and a year of enrollment. Students have an ID, a Last Name and First Name. A course passed by a Student has a mark and a date. Courses are teached by professors. Professors have a last name and a first name. They may be Associate Professors or Full professors, only for Full Professors we are interested to the City of Birth, with name and region. Every professor belongs to a Department. Departments have a Name and an address.

84 + Attributes of Relationships
Passed ID Last Name Name Enrolled in Student Course Year of Enrollment Professor First Name Associate Teach Full Professor Belongs to Grade Date Born in Department Address City Region

85 Minimum and maximum cardinalities

86 Cardinalities Student Course Student instances Course instances
Student ID Surname Student instances Course instances # of instances of Student in Enrolled # of instances of Student in Passed S1 1 S2 2 S3 Min Max # of instances of Course in Enrolled # of instances of Course in Passed C1 2 1 C2 C3 Min Max Enrolled Passed Course ID Course Name Course C3 <5, Algebra> S2 <21, Wang> C1 <3, Algorithms> S1 <13, Batini> C2 <7, Databases> S3 <32, Xu> Enrolled Passed

87 Cardinalities Student Course Student instances Course instances
Student ID Surname Student instances Course instances # of instances of Student in Enrolled # of instances of Student in Passed S1 1 S2 2 S3 Min Max # of instances of Course in Enrolled # of instances of Course in Passed C1 2 1 C2 C3 Min Max Enrolled Passed Course ID Course Name Course <5, Algebra> C3 S2 <21, Wang> C1 <3, Algorithms> S1 <13, Batini> C2 <7, Databases> S3 <32, Xu> Enrolled Passed

88 Minimum and maximum cardinalities
Student instances Course instances # of instances of Student in Enrolled # of instances of Student in Passed S1 1 S2 2 S3 Min Max # of instances of Course in Enrolled # of instances of Course in Passed C1 2 1 C2 C3 Min Max

89 Minimum and maximum cardinalities
Student instances Course instances # of instances of Student in Enrolled # of instances of Student in Passed S1 1 S2 2 S3 Min 1  1 0  0 Max 2  n 2  n # of instances of Course in Enrolled # of instances of Course in Passed C1 2 1 C2 C3 Min 2  1 1  1 Max 2  n 2  n

90 Cardinalities (1,n) (0,n) Student Course Student ID Surname Enrolled
Passed (1,n) (0,n) Course ID Course Name

91 Student Course City Major of Municipality First Name Last Name one
Student ID Surname Enrolled Course Course ID Course Name (1,n) many of Municipality Name Region (1,1) one Born City Country

92 Compact notation Major Student Municipality Course Student City one
First Name Last Name of Municipality Name Region one Student Student ID Surname Enrolled Course Course ID Course Name many Student Student ID Surname one Born many Name Country City

93 Compact notation Student Major Course Municipality Student City of
Student ID Surname Enrolled Course Course ID Course Name Major First Name Last Name of Municipality Name Region Student Student ID Surname Born Name Country City

94 Course ID Course Course Name

95 Identifiers

96

97 Question Student Student ID Surname Place of Birth
Student2 <Id = 41, Surname = Rossi, Place of Birth = Milan> Student2 <Id = 37, Surname = Batini, Place of Birth = Rome> Student2 <Id = 53, Surname = Wang, Place of Birth = Harbin>

98 Question Student Student ID Last Name Year of Birth
Student1 <Id = 41, Last Name = Rossi, Year of Birth = 1995> Student2 <Id = 37, Last Name = Batini, Year of Birth = 1994> Student3 <Id = 53, Last Name = Wang, Year of Birth = 1993> Student4 <Id = 71, Last Name = Wang, Year of Birth = 1994> Student5 <Id = 61, Last Name = Wang, Year of Birth = 1993> Student6 <Id = 78, Last Name = Li, Year of Birth = 1994> Student7 <Id = 81, Last Name = Li, Year of Birth = 1995>

99

100 Question Student Student Id Last Name Year of Birth
Student1 <Id = 41, Last Name = Rossi, Place of Birth = Milan, Year of Birth = 1993> Student2 <Id = 37, Last Name = Wang, Place of Birth = Harbin, Year of Birth = 1990> Student3 <Id = 53, Last Name = Wang, Place of Birth = Harbin, Year of Birth = 1993>

101 Internal Identifiers Student Student Student Id Given Name Last Name
Year of Birth Given Name Date of Birth Place of Birth Home address Student Last Name Given Name Date of Birth Place of Birth Home address

102 Identifier Student Id Student Surname Name

103 External Identifiers Student University Student University Enrolled in
Student ID Student Given Name Last Name one Enrolled in many University University Id University Name City Student Student ID Given Name University Enrolled in University Id City Last Name one many University Name

104 Exercise 2.2 – second part

105 Exercise second part Students of a University attend courses, and pass them. Courses have a last name, a first name and a year of enrollment. Students have an ID, a Last Name and First Name. A course passed by a Student has a mark and a date. Courses are teached by professors. Professors have a last name and a first name. They may be Associate Professors or Full professors, only for Full Professors we are interested to the City of Birth, with name and region. Every professor belongs to a Department. Departments have a Name and an address. Find minimum and maximum cardinalities and Identifiers

106 Cardinalities (one to one, one to many, many to many)
Students of a University attend courses, and pass them. Courses have a last name, a first name and a year of enrollment. Students have an ID, a Last Name and First Name. A course passed by a Student has a mark and a date. Courses are teached by professors. Professors have a last name and a first name. They may be Associate Professors or Full professors, only for Full Professors we are interested to the City of Birth, with name and region. Every professor belongs to a Department. Departments have a Name and an address.

107 Final schema of first part
Passed ID Last Name Name Enrolled in Student Course Year of Enrollment Professor First Name Associate Teach Full Professor Belongs to Grade Date Department Address City Region

108 Extended notation for cards

109 Extended notation for cards
Passed ID Last Name Name Enrolled in Student Course Year of Enrollment Professor First Name Associate Teach Full Professor Member of Grade Date Born in Department Address City Region (1,n) (1,n) (0,n) (1,n) (1,1) (1,n) (1,1) (1,n) (1,1) (1,n)

110 Compact notation

111 Compact notation for cards
First Name ID Last Name Name Year of Enrollment many many Enrolled in Student Course many many Passed one Teach Grade Date many First Name one Professor Belongs to Last Name many Name Region Full Professor Department Associate Professor one many City Born in Name Address

112 Identifiers Enrolled in Student Course Passed Professor Belongs to
First Name ID Last Name Name Year of Enrollment many many Enrolled in Student Course many many Passed one Teach Professor First Name Last many Grade Date one Belongs to many Name Region Full Professor Department Associate Professor one many City Born in Name Address

113 Exercise 2.7 – third part Assume we are in China. How should you modify the schema in case we want to distinguish between Chinese Students and Foreign Students. For Chinese Students we want to represent the City of Birth with Name and Region, for Foreign Students we want to represent the Country and the Continent of Birth.

114 Input schema to Exercise 2.7 - third part
First Name ID Last Name Name Year of Enrollment many many Enrolled in Student Course many many Passed one Teach Grade Date many First Name Professor Department Belongs to Last Name many one Name Address Full Professor Associate Professor Name Region one many City Born in

115 Input schema to Exercise 2.7 - third part
First Name ID Last Name Name Year of Enrollment many many Enrolled in Student Course many many Passed one Teach Department (1,n) Name Address Grade Date many First Name one Professor Belongs to Last Name Full Professor Associate Professor one Name many (1,1) City Born in Region (1,n)

116 Exercise 2.7 – input schema to the third part
ID Last Name First Name Name Year of Enrollment Passed Enrolled in Course (1,n) (0,n) Student Grade Date (1,1) Teach (1,n) First Name Professor (1,n) (1,1) Last Name Belongs to Department Associate Professor Full Professor Name Address Name City Born in (1,1) (1,n) Region

117 Exercise 2.7 - third part Course Student Foreign St. Chinese St.
ID Last Name First Name Name Year of Enrollment City Born in (1,1) (1,n) Professor First Name Teach Last Region Associate Full Professor Department Belongs to Address Passed Enrolled in Course (0,n) Grade Date Chinese St. Foreign St. Born Country Continent Student


Download ppt "University of Milano Bicocca, Italy Carlo Batini"

Similar presentations


Ads by Google