Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
School of Information Technology & Computer Science University of Wollongong Session: 3, July 2013 Lecturer: Janusz R. Getta CSCI315 Database Design and Implementation Singapore 2013-3 Assignment 2 Solution Tasks Task 1 (1 mark) Conceptual modelling, detailed analysis Read the following children's poem taken from http://storyit.com/Classics/JustPoems/rainbow.htm The Rainbow Christina Rossetti Boats sail on the rivers, And ships sail on the seas; But clouds that sail across the sky Are prettier than these. There are bridges on the rivers, As pretty as you please; But the bow that bridges heaven, And overtops the trees, And builds a road from earth to sky, Is prettier far than these. Analyse the poem given above and consider it as a specification of a sample database domain. Next, restructure it into a number of small semantically homogeneous paragraphs, i.e. the paragraphs that describe the common elements of the sample domain. Next, use a methodology described in a presentation 04 Object modelling, Case 1 to design a conceptual schema for the sample domain given above. The design process must follow a methodology in which new elements of a design are iteratively discovered and added to the individual conceptual schemas. You have to read ("pass" through) the specification divided into the paragraph several times and in each "pass" you have to discover different components of a design. The attributes and identifiers of the classes are up to you. For example, in the first pass you must discover the classes of objects, in the second pass, you discover the aggregations, in the third pass, you discover generalizations, then attributes, and so on. At the end of all passes you should obtain a number of small conceptual schemas, one for each of the individual paragraphs of the specification. Next, in the final stage you must integrate the individual schemas into the final design. Implement a Powerpoint presentation that shows your design process in the same way as it is done in a presentation 04 Object modelling, Case 1. A starting point for your presentation is a specification of a sample database domain given above. It means that the first slide must contain a text given above. The second slide must contain the original text after restructuring into homogeneous paragraphs. All steps of your design must be included in the presentation. The last slide must contain the final conceptual schema. There is no need to convert the final conceptual schema into the relational schemas. The conceptual schema must be expressed in a notation of simplified UML object classes explained to you during the lecture classes in the subject. Deliverables A file solution1.pdf with a Powerpoint presentation, that shows your design process. A presentation must be saved in pdf file in a format of one slide per page. To draw a conceptual schema you may use a file drawing-patterns.ppt that contains all graphical components of simplified UML classes in Powerpoint format. A submission in a format other from pdf will require an evaluator to convert your document into pdf format and evaluator will charge you 0.5 of a mark for such service. Solution See a file solution1.pdf Task 2 (2 marks) Conceptual modelling from a narrative specification of database domain Consider the following description of a sample database domain. Accordingly to Wikipedia "Greasy pole or grease pole refers to a pole that has been made slippery and thus difficult to grip. Greasy pole climbing is a name of events that involve staying on, climbing up, walking over or otherwise traversing such a pole." World Tour Championships in Greasy Pole Climbing (WTC-GPC) competitions include only climbing of vertical greasy poles. At the beginning of a year WTC-GPC competitions are scheduled at several locations around the world. A description of a competition includes date when it suppose to happen, country and city. During a competition the referees measure time needed by a climber to reach a platform located at the top of a pole while climbing from an earth level. A climber, with the shortest time wins a competition. All competitors who fail to reach a platform are disqualified and score no points towards all rounds yearly WTC-GPC classification. The competitors are described by first name, last name, date of birth and nationality. Full name and date of birth uniquely identifies each competitor. At the end of a competition the score points are awarded towards yearly classification. WTC-GPC registers the personal details of professional climbers together with a ranking, and total money prizes. The points collected at each competition add up towards the total yearly score. A competitor who scores the largest total number of points wins the prize of Golden Greasy Pole at the end of a season. The competitions are organized in many locations all over the world. At the beginning of the climbing season the organizers prepare the schedule of all events. Some competitions additionally host the special events, like baby and junior competitions, over 60+ competitions, rock concerts, promotional sessions etc. A list of such additional events is always appended to the schedules of the WTC-GPC competitions. The competitors must register an event before the participation. When a registration is completed the organizers decide on an order in which the competitors will attempt climbing a greasy pole. Usually a competitor with the lowest rank starts first. There are three round of climbing. A competitor is allowed to participate in all rounds to get the best time however, it is not compulsory. A very good result scored in the first round may be enough to win a competition. The results of all climbing attempts are recorded. An individual competitor who clocks the shortest climbing time wins a particular classification e.g. male, female, double, mixed. The first 10 competitors obtain WTCGPC points in their classification. The points are collected all over the year and at the end a climber or a team with the large total number of points the trophy. The up to date standings are maintained by WTC-GPC all over the year on their Web site. Use a notation of simplified UML classes of objects to design a conceptual schema of the database. Make sure that a schema of your database does not contain redundancies and it correctly represents all information that should be included in the database. Verify the correctness of your design with a "checklist" included in a presentation 09 Quality of conceptual schemas Part 2, slides 18 and 19. Only the final conceptual schema is expected. There is no need to present the intermediate stages of your design. Deliverables A file solution2.pdf with a drawing of conceptual schema expressed in a notation of simplified UML object classes. To draw a conceptual schema you may use a file drawing-patterns.ppt that contains all graphical components of simplified UML classes in Powerpoint format. A submission in a format other from pdf will require an evaluator to convert your document into pdf format and evaluator will charge you 0.5 of a mark for such service. Solution Task 3 (2 marks) Conceptual modelling from a functional specification of database domain A hospital would like to create a database to store information about the doctors, nurses, and patients treated at the hospital. Design a conceptual database schema such that the following database applications can be implemented and correctly retrieve information from the database. (1) List the names of all doctors who treated a given patient admitted to a hospital in a given period of time. (2) List the names of all patients admitted to the hospital in a given period of time. (3) List the locations (a floor number, and a list of room numbers) of a ward with a given name, e.g. cardiology. (3) List the names of all nurses assigned to a given ward. (4) List the full names, employee number, employment date, and position occupied by all employees of the hospital. (5) List the specialization of a doctor identified by an employee number. (6) List the degree level of a nurse identified by an employee number. (7) List information about all treatments (date, description) applied to a given patient and doctors and nurses participating in the treatments. (8) List a location (room number and bed number) of a given patient. (9) List dates of all night shifts of a given nurse and a given period of time. (10) List the names of medications applied to a given patient in a give period of time. Use a notation of simplified UML classes of objects to design a conceptual schema of the database. Make sure that a schema of your database does not contain redundancies and it correctly represents all information that should be included in the database. Verify the correctness of your design with a "checklist" included in a presentation 09 Quality of conceptual schemas Part 2, slides 18 and 19. Only the final conceptual schema is expected. There is no need to present the intermediate stages of your design. Deliverables A file solution3.pdf with a drawing of conceptual schema expressed in a notation of simplified UML object classes. To draw a conceptual schema you may use a file drawing-patterns.ppt that contains all graphical components of simplified UML classes in Powerpoint format. A submission in a format other from pdf will require an evaluator to convert your document into pdf format and evaluator will charge you 0.5 of a mark for such service. Solution Task 4 (1 mark) Logical design Consider the following conceptual schema: (1) 0.5 mark Transform a conceptual schema given above into the relational schemas. Use association method to implement (eliminate) generalization. List all relational schemas obtained. Clearly identify the primary, candidate, foreign keys, and optional attributes (NULL/NOT NULL constraints). There is no need to write CREATE TABLE statements of SQL. When ready add the shadow diagrams to a conceptual schema given above. Solution ATTRIBUTE(name) PK = (name) EMPLOYEE(e#, fname, lname, dob, salary) PK = (e#) EMP_HAS_ATTR(e#, name, value) PK = (e#, name) FK1 = (e#) references EMPLOYEE(e#) FK2 = (name) references ATTRIBUTE(name) ADMIN(e#) PK =(e#) FK = (e#) references EMPLOYEE(e#) ADMIN_DUTY(e#, duty) PK = (e#, duty) FK = (e#) references ADMIN(e#) PROGRAMMER(e#) PK = (e#) FK = (e#) references EMPLOYEE(e#) MODULE(name, version, fspec) PK =(name, version) WORKS_ON(e#, name, version, when_started, when_compl) PK = (e#, name, version, when-started) FK1 = (e#) references PROGRAMMER(e#) FK2 = (name, version) references MODULE(name, version) NULL = when_compl FUNCTION(name, version, fname, plang, source_code) PK = (name, version, fname) FK = (name, version) references MODULE(name, version) (2) 0.5 mark Extend a conceptual schema obtained from step (1) with the information described below. - Functions have parameters, a single parameter is described by a name and type, some of the parameters are input parameters, some are output parameters, and some are input/output parameters. - Programmers are proficient in using one or more programming languages and have professional certifications confirming their programming skills in each one of the programming languages. There is no need to transform an extended conceptual schema into the relational schemas. Solution Deliverables A file solution4.pdf with the results of task (1) including the relational schemas and the original conceptual schema with the shadow diagrams and the results of task (2) including an extended conceptual schema. In the results of task (2) all extension and modification to the original schema must be presented in a different colour. All extensions and modifications presented in the same colour as the original schema will be ignored. As a starting point, you may use a file task4.ppt that contains the original conceptual schema in expressed in a notation of simplified UML classes in Powerpoint format. A submission in a format other from pdf will require an evaluator to convert your document into pdf format and evaluator will charge you 0.5 of a mark for such service. Task 5 (1 mark) Storage allocation Consider the following description of a sample database domain. A denormalized (1NF) relational table TREATMENT contains information about the medical treatments performed on the patients admitted to a hospital. A relational schema of table TREATMENT is the following. TREATMENT(health-insurance-number, patient-name, date-of-birth, treatment-date, treatment-description, nurse-involved) primary key = (health-insurance-number, treatment-date, nurse-involved) All attributes are NOT NULL. Note, that a relational table TREATMENT has been denormalized to 1NF such that it contains the names of all nurses involved in each treatment. The denormalization requires repetition of some information included in the relational table. To correctly estimate the amounts of redundant data assume, that on average 2 nurses are involved in each treatment. Additionally, whenever the treatments are applied to a patient with the same health insurance number, a name and date of birth of the patient are repeated for each treatment. Storage requirements for the values of attributes are as follows. health-insurance-number 10 bytes, patient-name on average 20 bytes, date-of-birth 10 bytes, treatment-date 10 bytes, treatment-description on average 1000 bytes, nurse-involved 10 bytes. Assume that a relational table TREATMENT is never updated and its rows are never deleted. An average number of medical treatments performed per day is 20. Assume that treatments are performed over 300 days per year. Estimate the amounts of storage required to keep in information about the medical treatments performed at the hospital in a period of 10 years. Consider a database system where: size of database disk block is equal to 8K, size of block header is equal to 100 bytes, we ignore table headers, size of an entry in a row directory is equal to 2 bytes A value of PCTFREE parameter must be computed from information given above. Use the model of data block explained to you during the lecture classes in this subject. Show all calculations. Deliverables A file solution5.pdf with all calculations of storage requirements. A submission in a format other from pdf will require an evaluator to convert your document into pdf format and evaluator will charge you 0.5 of a mark for such service. Solution The total number of rows in a relational table TREATMENT, that stores information about the medical treatments is equal to the total number treatments per day * the total number of days per year * the total number of years * an average number of nurses per treatment = 20 * 300 * 10 * 2 = 12 * 104 An average row size is equal to 10 + 20 + 10 + 10 + 1000 + 10 = 1060 bytes. PCTFREE = 0 (see specification above). Total block header: tbh = 100 + 2*r Available data space per block: ads = (8192 – 100 – 2*r) * 1.0= = (8092 – 2*r) * 1.0 = 8029 – 2*r Average number of rows per block: r = (8029 – 2*r)/1060 r ≅ (7.63 – 0.002*r) r ≅ 7.63/1.002 r ≅ 7.62 Total number of blocks ≅ 12*104/7.62 ≅ 15748 Total number of bytes ≅ 15748 * 8192 ≅ 129007616 ≅ 130 Mbytes. End of solutions