EXERCISES WEEK 1 In this week, you exercise basic data modeling techniques: classes, objects, associations, links, and constraints. You practice with creating simple data models. You can create your models on paper or with a (cloud-based) editor for class diagrams on your laptop, like Visual Paradigm. However, object diagrams cannot be created in editors like Visual Paradigm. 1. INTRODUCING CLASSES AND OBJECTS Draw a class Student that has as attributes student number, student name, and date of birth. Draw an object Ron which is from the class Student. Ron has student number 0001 and is born on 01-01-1985. MODEL SOLUTION 0001 : Student Student Nr = 0001 Name = Ron BirthDate = 01-01-1985 Nr Name BirthDate 2. USING CLASSES, OBJECTS, ASSOCIATIONS, AND LINKS Draw a class diagram that has two classes: Student and Course: a. Connect the Student class with the Course class using an association. b. Add three relevant attributes for each of the classes. For example, for the class Student you may define student number, student name, and date of birth. c. Add multiplicity constrains on both ends of the association: a student takes one or more courses; a course is taken by zero or more students. Draw an object diagram in which Ron (an object from the class Student) takes the BIM course (an object from the Course class). Provide values for all attributes of the objects. MODEL SOLUTION Student Nr Name BirthDate takes * 1..* Course Nr Name Abbreviation 0001 : Student 1BV00 : Course Nr = 0001 Name = Ron BirthDate = 01-01-1985 Nr = 1BV00 Name = Business Modeling Abbreviation = BM 3. PERSON IS EMPLOYEE OF COMPANY Draw a class diagram described by the fact Person is Employee of Company and the following statements: a. b. c. d. It is possible that some Person is not Employee of any Company. Each Person is Employee of at most one Company. Each Company has at least one Person as Employee. It is possible that the same Company has more than one Person as Employee. (Draw one class diagram that addresses all these statements) MODEL SOLUTION Person Employee 1..* Company 0..1 4. STUDENT TAKES EXAM a. Model in an object diagram the fact that Ron (whose student number is 237784) takes the 1BB50 exam on 6-Oct-2003. b. Model the more general situation of students taking exams with the help of a class diagram. c. Attach sample extensions (populations) to all classes and associations in your model. d. Which are the unique attributes in this model? Notice that it should not be possible to have more than one exam per course per day. e. Is it compatible with your class diagram for a person to take more than one exam? If this is not the case, change the class diagram in a way, which makes this possible. MODEL SOLUTION 237784 : Student 1BB50 20031006 : Exam StudentNo = 237784 Name = Ron CourseNo = 1BB50 Date = 06-10-2003 takes/is taken by Student {unique} StudentNo Name Exam CourseNo Date * * 237784 237784 268315 268315 237784 Ron 215497 Ton 268315 Els {unique} 1BB50-20031006 1R620-20031119 1R620-20031119 1BB50-20031117 1BB50 06-Oct-2003 1BB50 17-Nov-2003 1R620 19-Nov-2003 Note 1: The object identifier in the case of the Exam class is a combination of two attributes: CourseNo and Date. This ensures that there is only one exam for a given course on a given date. Note 2: The object identifier is given both in the name of the object and also as value in the class attributes. Although it may seem redundant, it is not. One indicates the attribute to which this value belongs, and the other one indicates that this is the object identifier. 5. CONFERENCE MANAGEMENT In the problem domain of conference management, we may use a class Session for representing the different sessions of a conference, which consist of a number of paper presentations, and a class Participant for representing the conference participants. The following class diagram also contains the chairperson association between Session and Participant: * 1 ChairPerson 3 joins Session Participant * * a. Is it compatible with the class diagram for a participant to be the chairperson of multiple sessions at a conference? If not, change the class diagram in such a way that makes this possible. b. Add attributes and attach sample extensions (populations) to the classes and the association in this diagram. c. Change the class diagram in such a way, which makes it possible for some sessions (for instance, the main sessions) to have a vice-chairperson (note that a class may be associated in different ways to another class). d. Suppose participants evaluate sessions. Extend the class diagram in such a way that it becomes possible for participants to grade sessions in a session evaluation. e. Further extend the class diagram such that a session evaluation includes a number of paper evaluations, and it becomes possible to evaluate each paper with a grade. MODEL SOLUTION a+b * 1 Session 3 joins SessionNo SessionName StartTime Participant * ParticipantNo Name * A1 Theory 9:00 A2 Applications 14:00 B1 Case studies 16:00 A1 A2 B1 ChairPerson 003 017 035 017 003 003 Grefen Reijers Angelov c+d+e * 1 1 ChairPerson 1 3 joins Session Participant * 1 * * ViceChairPerson 0..1 {unique} 3 madeFor madeBy4 SessionEvaluation -Grade * * 1 * PaperEvaluation Paper * 1 * -Grade Note: The uniqueness constraint here is used to indicate that each participant can give only one evaluation per session. This constraint can be modeled also in a different way (to be demonstrated in the next lecture). 6. COURSE PREREQUISITES The following class diagram describes some concepts from the problem domain of university course management. Courses are given by faculty members. Courses have pre-requisites, that is, certain other courses have to be taken before a specific course can be attended. prerequisite isGivenBy Course FacultyMember CourseID CourseName 0..1 * * 1 a. Verbalize the recursive association between courses. Using CourseID as the standard identifier of the Course class, give a sample extension (population) for this class and the recursive association. b. Is it compatible with the given class diagram that a course can have more than one prerequisite course? If this is not the case, change the class diagram in such a way that makes this possible. c. Is it possible for several courses to have the same course as a prerequisite? If this is not the case, change the class diagram in such a way that makes it possible. d. Express a constraint that prevents a course from being its own pre-requisite. MODEL SOLUTION a) Each course has zero or one course as prerequisite. Each prerequisite course has one (successor) course. CourseID IIS10 IBB30 IIS40 IBB80 CourseName IS Basic DOM IS Advance OO Programming Pre-requisite IIS10 IBB30 CourseID IIS40 IBB80 b) No, it is not possible, because of the "1" multiplicity in the "0..1" constraint. c) and d) prerequisite * isGivenBy Course CourseID CourseName FacultyMember * * 1..* {A course must not be its own prerequisite.} 7. R&D PROJECT FUNDING Governmental agencies use certain rules for funding research and development (R&D) projects. The following remarks describe an information system that helps to put together committees for evaluating R&D project proposals. In general, a new R&D funding program is started by issuing a call for proposals (CFP) that specifies a number of themes for which project proposals can be submitted. When the submission deadline has passed, the project proposals submitted for a specific theme are evaluated by a committee composed of external experts that are competent for this theme. One of the committee members is appointed as chairperson. A theme may appear in more than one CFP. A CFP has a unique reference number, a research program name, a date of publication, and an available budget. The following information about experts is kept up-to-date: a unique identification number, name, gender, date of birth, and the themes for which the expert is competent. Make a class diagram including the most important object classes and constraints. MODEL SOLUTION 1..* 1 isEvaluatedBy 0..1 ProjectProposal Committee * * * * refersTo isSubmittedInResponseTo {unique} 3 isMemberOf 1 2..* 1 CFP RefNo ProgramName DateOfPublication Budget SubmissionDeadline 1 {unique} Expert Theme * 1..* * * ExpertID Name Gender DateOfBirth 1 Chairperson {Chairperson of committee must be member of committee } Optional: for isMemberOf association, use role name Member at end of Expert 8. EXEMPTIONS AT THE OPEN UNIVERSITY Students at the Open University (OU) have often completed other studies before they start studying at the OU. They are usually eligible for exemption from part of their study programme at the OU, as a result of their previous studies. A simplified description of the process involved in such an exemption request is given below for someone hoping to study information science. An information system for handling the exemption requests and decisions is to be developed. For each student, a student number, name and address are registered. Many students have completed one previous course of study; for example, Information Science at a higher technical college (HTS), Dutch law or Tourism studies. There are now two possibilities: Possibility 1 For several common types of previous study (such as Information Science at HTS), there are standard exemption profiles (one for each previous study). Such a profile shows whether or not there will be an exemption, for each subject to be followed at the OU. If the student has completed one of these previous studies, the exemption decision for a subject will be justified by means of the profile that applies to the student. Possibility 2 If the student’s previous study does not fit into any standard profile, then the student must hand in a request for which subjects he or she would like to be exempted. The decision, whether or not an exemption is granted, is then registered per subject. If no exemption is granted for a particular subject, then the reason for that is also registered. Make a class diagram. State any assumptions that you have made. MODEL SOLUTION Student StudNo Name Address * 0..1 3 isFor hasCompleted Study ExemptionProfile 1 * 0..1 * exempts 1 isReasonFor 1..* makes refersTo ExemptionRequest * 1 Subject * 1..* 1 * 1 consistOf ExemptionDecision 1 1..* ExemptionDecisionBySubject Decision Reason *