Академический Документы
Профессиональный Документы
Культура Документы
Instructions
1. This is Assignment (Nr. 1 of 2) and contributes 10% to your semester mark for this course.
2. The deadline for this assignment 1 is: Monday 19th March 2012 23:59 Hrs.
3. Please feel free to contact Mr. Colin Stanley if you have any questions or problems regarding
this assignment.
4. Students will not be reminded about outstanding assignments. All assignment s not handed in
Page 2 of 5
1. Assignment Scenario
Imagine that you are employed as a Database Developer at the Windhoek Community Service Organisation (W.C.S). The main role of this organisation to is to help families to find people who can take care of their old or sick relatives. WCSs database has the following four tables:
Families stores the general information about the individual families Contact_persons stores the old or sick relative details of the families Needs stores the general requirements specified by the old or sick relative that the helper or care taker should fulfil Care_takers stores the information about those people (care takers) willing to assist the old or sick the people of the families
surname that has the letter z has the second letter and ends with the letter e and stays in Windhoek north. [5 Marks]
SELECT family_id AS "Family ID", first_name AS "Name", street_address AS "Street Address", location FROM families WHERE surname LIKE '_z%e' and LOWER(location) LIKE LOWER('Windhoek north'); 2 marks for all columns specified and 1 mark for proper use of alias 1 mark for the surname pattern search 1 mark for location search (if string is as used as specified than lower function should be used)
Page 3 of 5
3.2 That displays the old or sick person name, sickness details and the language they speak
Kwanyama, Diriku and Nama. The information should be sorted in descending order by the persons name. [5 Marks]
SELECT first_name "Sick Person Name", sickness "Sickness", language_spoken "Language Spoken" FROM contact_persons WHERE language_spoken IN ('Kwanyama', 'Diriku', 'Nama') ORDER BY 1 desc; 2 marks for all columns specified and 1 mark for proper use of alias 1 mark for the language condition 1 mark for family surname ORDER BY clause 3.3 That will concatenate the care takers name with his or her qualification, in between there
should be a string has a and append the string degree at the end of the concatenation, the column should read as Qualification. Also displays the age and its category using a case expression as follows; age in the range of 17 to 19 as Teenage, 20 to 30 as Lady or Gentlemen and above or below the specified range as Adolescent or Elderly, the resulted column should read as Age Category. [10 Marks] The table 1 below depicts the sample result:
Table 1 QUALIFICATION Nokuthula has a Nursing degree Kelly has a Nursing degree Megan has a Nurse Practitioner degree Robyn has a Nurse Practitioner degree Hannah has a Nurse Practitioner degree Ina-Cherie has a First Aid degree Lil has a First Aid degree AGE 21 25 30 18 18 19 20 Age Category Lady or Gentlemen Lady or Gentlemen Lady or Gentlemen Teenage Teenage Teenage Lady or Gentlemen
SELECT INITCAP(first_name) || ' has a ' ||qualification || ' degree ' AS Qualification, age, (CASE WHEN age BETWEEN 17 AND 19 THEN 'Teenage' WHEN age BETWEEN 20 AND 30 THEN 'Lady or Gentlemen' ELSE 'Adolescent or Elderly' END) "Age Category" FROM care_takers; 2 marks for all the columns specified and 1 mark for proper use of alias 1 mark for initcap for first name 6 marks for the correct use of the case expression Page 4 of 5
3.4 Displays the surname, nationality and qualification all those care takers that still have not
started working
SELECT surname, nationality, qualification FROM care_takers WHERE start_date IS NULL; 1 mark all the columns specified and 2 marks for the start date condition
[3 Marks]
3.5 Using a variable Work_StartDate write an SQL statement that would select the sick
needs specification of week days, age and start date from needs that started working before or on the value of Work_StartDate that you defined. [3 Marks]
DEFINE Work_StartDate = '01-MAR-12' SELECT weekday, age, start_date FROM needs WHERE start_date <= '&Work_StartDate'; 1 mark for defined variable, 1 mark all the columns specified and 1 mark for the where condition
3.6 That display the average age for every language spoken from the family needs table.
[2 Marks] SELECT LANGUAGE_SPOKEN, AVG(age) FROM needs GROUP BY LANGUAGE_SPOKEN; 1 mark for columns specified including use of average function and 1 mark for group by clause TOTAL [30]
4 Deliverable guidelines:
4.1 All your SQL solution statements should be saved in one script file name as your student
Assignment 1 folder (should have your student number as well) and another one as a hard copy to your group lecturer. 4.4 No email submission would be accepted.
Page 5 of 5