EDUOPEN Carlo Batini University of Milano Bicocca, Italy batini@disco EDUOPEN Carlo Batini University of Milano Bicocca, Italy batini@disco.unimib.it Assignment on Conceptual design
Diagrammatic representation adopted
Diagrammatic representation Construct of the ER model Diagrammatic representation Entity Attribute of entity Relationship Attribute of relationship Is-a hierarchy Generalization hierarchy Internal Identifier External Identifier Name Name Name of attribute Name Name Name of attribute Name Name of attribute Name of attribute Name Name
Furthermore… When the internal identifier is made of two/n attributes we will write: Att1 & Att2 & ….. …… Attn Name
Certification Exercise - 1 Read carefully the following requirements
Structure of requirements in six parts R1 – A Municipality (e.g. the municipality of Milan, Italy) aims at managing in a given year (e.g. in 2018) a bike sharing service. The service is organized in terms of parking lots, each one identifed by a code, a longitude, a latitude, an address, a name (e.g. Piazzale Susa), and by a number of locations for bycicles. Each location is identified by a progressive number in the parking and from the type of bike that can be hosted in the location, namely a. normal or b. assisted (namely, equipped with an electric motor). We assume that in a specific location of a parking lot it is always parked a bike of a given type. R2 - Each bike is identified by a numeric code, and a date of purchase; assisted bikes have a make, that may change among bikes (we do not represent the makes of normal bikes). R3 - When bikes are not used, they are parked in locations of parking lots. As a consequence, for each bike and for each minute in the year (e.g. minute 34 of hour 10 a.m. of march 7th) we want to represent the state of the bike, namely if it is parked or it is in motion. Furthermore, for each minute in the year and each location in a parking lot, we want to represent, separately, which bike is possibly parked in the location (e.g. in minute 29 of hour 11 a.m. of march 21th bike 73 is parked in location 15 of parking lot 28, while in the same minute bike 130 is parked in location 6 of parking lot 112). Of course, if in a given minute a bike is in motion, the corresponding location in a parking lot does not exist, and, therefore, will not be represented. It is strongly recommended to represent the concept of minute with an Entity. R4 – In order to use bikes, users have to register themselves. A registered user is characterized by an identifier (e.g. a fiscal code, or a social security number), a progressive numeric code (first person registered, second person registered, etc.) a name, a surname, date of birth, municipality of birth, with code, name of municipality and region (we assume that municipalities are located in regions). R5 – Everytime a user picks up and subsequently returns a bike, such an event (pick up and return of a bike by a user) has to be recorded. The event is identified by a progressive number in the year (e.g. first event in 2015, second event in 2015, etc.) and duration (e.g. 12 minutes, 47 minutes); such duration has to be explicitely represented in the data base. The minute of pick up and the minute of return have to be associated to the event, besides, of course, the bike used and the user involved. R6 – One or more credit cards are associated to users, with type (e.g. Visa, Diners), progressive code in the card type, and daily maximum amount of withdrawal (that depends on the card and on the person). You have to represent above requirements with an Entity Relationship Schema, in terms of entities, relationships, attributes, internal and external idetitifers, generalizations, is-a relationships, minimum and maximum cardinalities.
Certification Exercise - 2 For requirements R1 to R6 you have to choose among the several schemas proposed a schema representing requirements Once you have chosen the schema for, say, requirements R1, the correct solution among schemas proposed is shown to you; at this point, you have to move to requirements R2, and so on, until you reach requirements R6. At this point the self assessment is finished.
Grades for the correct solution Requirements Grade of the correct solution R1 15 R2 10 R3 25 R4 R5 R6 Total 100
Requirements R1 (15 points)
Requirements R1 R1 – A Municipality (e.g. the municipality of Milan, Italy) aims at managing in a given year (e.g. in 2018) a bike sharing service. The service is organized in terms of parking lots, each one identifed by a code, a longitude, a latitude, an address, a name (e.g. Piazzale Susa), and by a number of locations for bycicles. Each location is identified by a progressive number in the parking and from the type of bike that can be hosted in the location, namely a. normal or b. assisted (namely, equipped with an electric motor). We assume that in a specific location of a parking lot it is always parked a bike of a given type.
R1 - Choose among the following cases (1,1) (1,n) # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Parking (Lot) in B # numeric code Type of bike (1,1) (1,n) in Parking Code Longitude & Latitude Address Name # of locations Location C (1,n) (1,n) in Parking Code Longitude & Latitude Address Name # of locations # numeric code Type of bike Location D # numeric code Type of bike (1,1) (1,n) Code Longitude & Latitude Address Name # of locations Location in Parking
Requirements R1 Grades for the four solutions Grade of the correct solution A 15 B 9 C 5 D
Correct solution for requirements R1 # numeric code Type of bike (1,1) (1,n) Code Longitude & Latitude Address Name # of locations Location Parking (Lot) in
Requirements R2 (10 points)
Requirements R2 R1 – A Municipality (e.g. the municipality of Milan, Italy) aims at managing in a given year (e.g. in 2018) a bike sharing service. The service is organized in terms of parking lots, each one identifed by a code, a longitude, a latitude, an address, a name (e.g. Piazzale Susa), and by a number of locations for bycicles. Each location is identified by a progressive number in the parking and from the type of bike that can be hosted in the location, namely a. normal or b. assisted (namely, equipped with an electric motor). We assume that in a specific location of a parking lot it is always parked a bike of a given type. R2 - Each bike is identified by a numeric code, and a date of purchase; assisted bikes have a make, that may change among bikes (we do not represent the makes of normal bikes).
Choose among the following cases Bike Code Date of purchase Make A Bike Assisted Code Date of purchase make B Bike Normal Code Date of purchase Assisted make C Bike Code Date of purchase Type Make D
Requirements R2 Grades for the four solutions Grade of the correct solution A B 10 C D 7
Correct solution for requirements R1+R2 (1,1) (1,n) # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Parking (Lot) in Bike Normal Code Date of purchase Assisted make
Requirements R3 (20 points)
Requirements R3 R1 – A Municipality (e.g. the municipality of Milan, Italy) aims at managing in a given year (e.g. in 2018) a bike sharing service. The service is organized in terms of parking lots, each one identifed by a code, a longitude, a latitude, an address, a name (e.g. Piazzale Susa), and by a number of locations for bycicles. Each location is identified by a progressive number in the parking and from the type of bike that can be hosted in the location, namely a. normal or b. assisted (namely, equipped with an electric motor). We assume that in a specific location of a parking lot it is always parked a bike of a given type. R2 - Each bike is identified by a numeric code, and a date of purchase; assisted bikes have a make, that may change among bikes (we do not represent the makes of normal bikes). R3 - When bikes are not used, they are parked in locations of parking lots. As a consequence, for each bike and for each minute in the year (e.g. minute 34 of hour 10 a.m. of march 7th) we want to represent the state of the bike, namely if it is parked or it is in motion. Furthermore, for each minute in the year and each location in a parking lot, we want to represent, separately, which bike is possibly parked in the location (e.g. in minute 29 of hour 11 a.m. of march 21th bike 73 is parked in location 15 of parking lot 28, while in the same minute bike 130 is parked in location 6 of parking lot 112). Of course, if in a given minute a bike is in motion, the corresponding location in a parking lot does not exist, and, therefore, will not be represented. It is strongly recommended to represent the concept of minute with an Entity.
Requirements R3 Before your modeling of requirements, let us split requirements in R3 into two different paragraphs. R3.1 - When bikes are not used, they are parked in locations of parking lots. As a consequence, for each bike and for each minute in the year (e.g. minute 34 of hour 10 a.m. of march 7th) we want to represent the state of the bike, namely if it is parked or it is in motion. R3.2 - Furthermore, for each minute in the year and each location in a parking lot, we want to represent, separately, which bike is possibly parked in the location (e.g. in minute 29 of hour 11 a.m. of march 21th bike 73 is parked in location 15 of parking lot 28, while in the same minute bike 130 is parked in location 6 of parking lot 112). Of course, if in a given minute a bike is in motion, the corresponding location in a parking lot does not exist, and, therefore, will not be represented. It is strongly recommended to represent the concept of Minute with an Entity.
Solution A Location Parking Minute In 2015 Bike Assisted Normal (1,1) # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Minute & Hour & Day & Month Minute In 2015 (1,n) (1,n) Parked in State (1,n) Bike Code Date of purchase Assisted make Normal
Solution B Location Parking Minute In 2015 Bike Assisted Normal (1,1) # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Minute & Hour & Day & Month Minute In 2015 (1,n) (1,1) Parked in (1,1) On (1,n) State Bike Code Date of purchase (1,n) Assisted make Normal
Solution D Location Parking Minute In 2015 Bike Assisted Normal (1,1) # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Minute & Hour & Day & Month Minute In 2015 (1,n) (1,n) (1,n) Parked in State (1,n) Bike Code Date of purchase Assisted make Normal
Scores of the different solutions in modeling R3
Requirements R3 Grades for the four solutions Grade of the solution A 10 B 20 C 25 D
Correct Solution for requirements R1+R2+R3 (1,1) (1,n) in Parking Code Longitude & Latitude Address Name # of locations # numeric code Type of bike Location Minute & Hour & Day & Month Minute In 2015 (1,n) (1,n) Parked in (1,1) On (1,n) State Bike Code Date of purchase (1,n) Assisted make Normal
Requirements R4
Requirements R4 R1 – A Municipality (e.g. the municipality of Milan, Italy) aims at managing in a given year (e.g. in 2018) a bike sharing service. The service is organized in terms of parking lots, each one identifed by a code, a longitude, a latitude, an address, a name (e.g. Piazzale Susa), and by a number of locations for bycicles. Each location is identified by a progressive number in the parking and from the type of bike that can be hosted in the location, namely a. normal or b. assisted (namely, equipped with an electric motor). We assume that in a specific location of a parking lot it is always parked a bike of a given type. R2 - Each bike is identified by a numeric code, and a date of purchase; assisted bikes have a make, that may change among bikes (we do not represent the makes of normal bikes). R3 - When bikes are not used, they are parked in locations of parking lots. As a consequence, for each bike and for each minute in the year (e.g. minute 34 of hour 10 a.m. of march 7th) we want to represent the state of the bike, namely if it is parked or it is in motion. Furthermore, for each minute in the year and each location in a parking lot, we want to represent, separately, which bike is possibly parked in the location (e.g. in minute 29 of hour 11 a.m. of march 21th bike 73 is parked in location 15 of parking lot 28, while in the same minute bike 130 is parked in location 6 of parking lot 112). Of course, if in a given minute a bike is in motion, the corresponding location in a parking lot does not exist, and, therefore, will not be represented. It is strongly recommended to represent the concept of minute with an Entity. R4 – In order to use bikes, users have to register themselves. A registered user is characterized by an identifier (e.g. a fiscal code, or a social security number), a progressive numeric code (first person registered, second person registered, etc.) a name, a surname, date of birth, municipality of birth, with code, name of municipality and region (we assume that municipalities are located in regions).
Solution A Solution B Solution C Person Person Munici- pality Munici- Code Name Region Born in Person Id Numeric Code First Name Last Name (1,1) Munici- pality Solution A (1,n) Code Name Region Born in Registered Person Id First Name Last Name (1,1) Munici- pality Numeric Code Solution B (1,n) Code Name Region Born in Person Id Numeric Code First Name Last Name (1,1) Munici- pality Solution C
Solution D Solution E Person Person Munici- pality Region Id Numeric Code First Name Last Name Code of Municipality Name of Municipality Region Solution D (1,n) Code Name Born in Person Id Numeric Code First Name Last Name (1,1) Munici- pality Region Located in Solution E
Requirements R4 Grades for the five solutions Grade of the solution A 12 B 9 C 15 D E 8
Correct solution for requirements R1+R2+R3+R4 (1,1) (1,n) in Parking # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Minute & Hour & Day & Month Minute In 2015 (1,n) (1,n) Parked in (1,n) (1,n) on (1,n) (1,n) State picks up Bike Code Date of purchase (1,n) returns (1,n) (1,1) Assisted make concerns Id Numeric Code First Name Last Name Normal (1,n) (1,1) (1,1) Person Refers to Event # numeric code Period of time (1,1) (1,n) (1,1) Born in (1,n) Munici- pality Code Name Region
Requirements R5
Requirements R5 R1 – A Municipality (e.g. the municipality of Milan, Italy) aims at managing in a given year (e.g. in 2018) a bike sharing service. The service is organized in terms of parking lots, each one identifed by a code, a longitude, a latitude, an address, a name (e.g. Piazzale Susa), and by a number of locations for bycicles. Each location is identified by a progressive number in the parking and from the type of bike that can be hosted in the location, namely a. normal or b. assisted (namely, equipped with an electric motor). We assume that in a specific location of a parking lot it is always parked a bike of a given type. R2 - Each bike is identified by a numeric code, and a date of purchase; assisted bikes have a make, that may change among bikes (we do not represent the makes of normal bikes). R3 - When bikes are not used, they are parked in locations of parking lots. As a consequence, for each bike and for each minute in the year (e.g. minute 34 of hour 10 a.m. of march 7th) we want to represent the state of the bike, namely if it is parked or it is in motion. Furthermore, for each minute in the year and each location in a parking lot, we want to represent, separately, which bike is possibly parked in the location (e.g. in minute 29 of hour 11 a.m. of march 21th bike 73 is parked in location 15 of parking lot 28, while in the same minute bike 130 is parked in location 6 of parking lot 112). Of course, if in a given minute a bike is in motion, the corresponding location in a parking lot does not exist, and, therefore, will not be represented. It is strongly recommended to represent the concept of minute with an Entity. R4 – In order to use bikes, users have to register themselves. A registered user is characterized by an identifier (e.g. a fiscal code, or a social security number), a progressive numeric code (first person registered, second person registered, etc.) a name, a surname, date of birth, municipality of birth, with code, name of municipality and region (we assume that municipalities are located in regions). R5 – Everytime a user picks up and subsequently returns a bike, such an event (pick up and return of a bike by a user) has to be recorded. The event is identified by a progressive number in the year (e.g. first event in 2015, second event in 2015, etc.) and duration (e.g. 12 minutes, 47 minutes); such duration has to be explicitely represented in the data base. The minute of pick up and the minute of return have to be associated to the event, besides, of course, the bike used and the user involved.
For Requirements R5 we give the correct solution
Solution A - 25 Location Parking Minute In 2015 Bike Assisted Normal (1,1) (1,n) in Parking # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Minute & Hour & Day & Month Minute In 2015 (1,n) (1,n) Parked in (1,n) (1,n) on (1,n) (1,n) State picks up Bike Code Date of purchase (1,n) returns (1,n) (1,1) Assisted make concerns Id Numeric Code First Name Last Name Normal (1,n) (1,1) (1,1) Person Refers to Event # numeric code Period of time (1,1) (1,n) (1,1) Born in (1,n) Munici- pality Code Name Region
Question: which ones among the following solutions are correct?
Solution A - 25 Location Parking Minute In 2015 Bike Assisted Normal (1,1) (1,n) in Parking # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Minute & Hour & Day & Month Minute In 2015 (1,n) (1,n) Parked in (1,n) (1,n) on (1,n) State (1,n) Bike Code Date of purchase Picks up (1,n) (1,1) Assisted make concerns Id Numeric Code First Name Last Name Normal (1,n) (1,1) Person Refers to Event # numeric code Period of time (1,1) (1,n) (1,1) Born in (1,n) Munici- pality Code Name Region
Solution B Location Parking Minute In 2015 Bike Assisted Normal Person (1,1) (1,n) in Parking # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Minute & Hour & Day & Month Minute In 2015 (1,n) (1,n) Parked in (1,n) (1,n) on (1,n) (1,n) State picks up Bike Code Date of purchase (1,n) returns (1,n) (1,n) Assisted make concerns Id Numeric Code First Name Last Name Normal (1,n) (1,n) (1,n) Person Refers to Event # numeric code Period of time (1,1) (1,n) (1,1) Born in (1,n) Munici- pality Code Name Region
Solution C (1,1) (1,n) in Parking # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Minute Hour Day Month Minute In 2015 (1,n) (1,n) Parked in (1,n) (1,n) on (1,n) (1,n) State Bike Code Date of purchase Loan event (1,n) Progressive number period Assisted make Id Numeric Code First Name Last Name Normal (1,n) Person (1,n) (1,1) Remark This is a serious mistake, since in the ER model relationships correspond to functions whose domains consist in the Entities involved; so, relationships do not have identifiers. Born in (1,n) Munici- pality Code Name Region
Scores for Requirements R5 X means correct solution Solution A Solution B Solution C Score X 25 16 8
Correct solution for Requirements R1+R2+R3+R4+R5 (1,1) (1,n) in Parking # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Minute & Hour & Day & Month Minute In 2015 (1,n) (1,n) Parked in (1,n) (1,n) on (1,n) (1,n) State picks up Bike Code Date of purchase (1,n) returns (1,n) (1,n) Assisted make concerns Id Numeric Code First Name Last Name Normal (1,n) (1,n) (1,n) Person Refers to Event # numeric code Period of time (1,1) (1,n) (1,1) Born in (1,n) Munici- pality Code Name Region
Requirements R6
Requirements R6 R1 – A Municipality (e.g. the municipality of Milan, Italy) aims at managing in a given year (e.g. in 2018) a bike sharing service. The service is organized in terms of parking lots, each one identifed by a code, a longitude, a latitude, an address, a name (e.g. Piazzale Susa), and by a number of locations for bycicles. Each location is identified by a progressive number in the parking and from the type of bike that can be hosted in the location, namely a. normal or b. assisted (namely, equipped with an electric motor). We assume that in a specific location of a parking lot it is always parked a bike of a given type. R2 - Each bike is identified by a numeric code, and a date of purchase; assisted bikes have a make, that may change among bikes (we do not represent the makes of normal bikes). R3 - When bikes are not used, they are parked in locations of parking lots. As a consequence, for each bike and for each minute in the year (e.g. minute 34 of hour 10 a.m. of march 7th) we want to represent the state of the bike, namely if it is parked or it is in motion. Furthermore, for each minute in the year and each location in a parking lot, we want to represent, separately, which bike is possibly parked in the location (e.g. in minute 29 of hour 11 a.m. of march 21th bike 73 is parked in location 15 of parking lot 28, while in the same minute bike 130 is parked in location 6 of parking lot 112). Of course, if in a given minute a bike is in motion, the corresponding location in a parking lot does not exist, and, therefore, will not be represented. It is strongly recommended to represent the concept of minute with an Entity. R4 – In order to use bikes, users have to register themselves. A registered user is characterized by an identifier (e.g. a fiscal code, or a social security number), a progressive numeric code (first person registered, second person registered, etc.) a name, a surname, date of birth, municipality of birth, with code, name of municipality and region (we assume that municipalities are located in regions). R5 – Everytime a user picks up and subsequently returns a bike, such an event (pick up and return of a bike by a user) has to be recorded. The event is identified by a progressive number in the year (e.g. first event in 2015, second event in 2015, etc.) and duration (e.g. 12 minutes, 47 minutes); such duration has to be explicitely represented in the data base. The minute of pick up and the minute of return have to be associated to the event, besides, of course, the bike used and the user involved. R6 – One or more credit cards are associated to users, with type (e.g. Visa, Diners), progressive code in the card type, and daily maximum amount of withdrawal (that depends on the card and on the person).
Solution A Credit Card Person Type & Code (1,1) has Id Numeric Code First Name Last Name (1,n) Person Maximum am. of withdrawal
Solution B Credit Card Person Type Code (1,1) has Id Numeric Code First Name Last Name (1,n) Person maximum amount of withdrawal
Solution C Credit Card Person Type & Code (1,1) has maximum amount of withdrawal Id Numeric Code First Name Last Name (1,n) Person
Solution D Credit Card Person Type & Code (1,1) has maximum amount of withdrawal Id Numeric Code First Name Last Name (1,1) Person
Solution E Credit Card Person Type & Code Maximum am. of withdrawal (1,1) has Id Numeric Code First Name Last Name (1,n) Person
Solution F Credit Card Person Type Code (1,1) has maximum amount of withdrawal Id Numeric Code First Name Last Name (1,1) Person
Solution G Credit Card Person Type Code maximum amount of withdrawal (1,1) has Id Numeric Code First Name Last Name (1,n) Person
Solution H Credit Card Person Type Code maximum amount of withdrawal (1,1) has Id Numeric Code First Name Last Name (1,1) Person
Requirements R6 Grades for the correct solution Grade of the correct solution A 6 B 3 C 10 D E F G
Final Schema
Final correct solution (1,1) (1,n) in Parking # numeric code Type of bike Code Longitude & Latitude Address Name # of locations Location Minute Hour Day Month Type & Code Credit Card Minute In 2015 (1,n) (1,n) Parked in (1,n) (1,n) (1,1) on (1,n) (1,n) State picks up Code Date of purchase (1,n) Bike has maximum amount of withdrawal returns (1,n) concerns (1,1) Id Numeric Code First Name Last Name Assisted (1,1) Normal make (1,n) (1,1) (1,1) Person Refers to Event # numeric code Period of time (1,1) (1,n) (1,1) Born in (1,n) Munici- pality Code Name Region