IDB220S Assignment 1 MEMO

download IDB220S Assignment 1 MEMO

of 5

Transcript of IDB220S Assignment 1 MEMO

  • 8/2/2019 IDB220S Assignment 1 MEMO

    1/5

    Subject Code: IDB220S

    Subject: Introduction to Databases 1 B

    Semester: 1st Semester 2012

    Date Published: 6 March, 2012

    Assignment #: 1

    Topic: Data manipulation (Lesson 1 - 4)

    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 March2012 23:59 Hrs.

    3. Please feel free to contact Mr. Colin Stanley if you have any questions or problems regardingthis assignment.

    4. Students will not be reminded about outstanding assignments. All assignment s not handed in

    time will be marked with 0%.

    5. This assignment should be done individually and proper SQL coding is mandatory such

    comments, indentations, SQL keywords in uppercases, etc.

    6. Academic Honesty and Integrity of the Polytechnic of Namibia (as found in the undergraduate

    prospectus 2011, AC3.2 page 22) is fully applicable to this assignment.

    Polytechnic of NamibiaSchool of Information TechnologyDepartment of Software EngineeringPrivate Bag 13388, 13 Storch Street, Windhoek, Namibia

    Tel: +264-(0)61-207-2052 Fax: +264-(0)61-207-2051

  • 8/2/2019 IDB220S Assignment 1 MEMO

    2/5

    This assignmentpaper consists of 4 pages (including the front page).

    Page 2 of5

  • 8/2/2019 IDB220S Assignment 1 MEMO

    3/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

    2. Database Schema Setup

    2.1Load and execute the schema file titled IDB220S_Assignment1.sql [0 Mark]

    2.2 Write an SQL statement that would display all the tables inside the database.[1 Mark]

    2.3 Write an SQL statement that would provide information about the families table structure.

    [1 Mark]

    3

    Write SQL statements that would perform the following:3.1That displays the family id, name, street address and location of all those families who has a

    surname that has the letter z has the second letter and ends with the letter e and stays inWindhoek north. [5 Marks]

    SELECT family_id AS "Family ID", first_name AS "Name",street_address AS "Street Address", locationFROM 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 alias1 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 of5

  • 8/2/2019 IDB220S Assignment 1 MEMO

    4/5

    3.2That 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 thepersons 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 caseexpression 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 AGE Age Category

    Nokuthula has a Nursing degree 21 Lady or Gentlemen

    Kelly has a Nursing degree 25 Lady or Gentlemen

    Megan has a Nurse Practitioner degree 30 Lady or Gentlemen

    Robyn has a Nurse Practitioner degree 18 Teenage

    Hannah has a Nurse Practitioner degree 18 Teenage

    Ina-Cherie has a First Aid degree 19 Teenage

    Lil has a First Aid degree 20 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 of5

  • 8/2/2019 IDB220S Assignment 1 MEMO

    5/5

    3.4 Displays the surname, nationality and qualification all those care takers that still have not

    started working [3 Marks]

    SELECT surname, nationality, qualificationFROM care_takers

    WHERE start_date IS NULL;

    1 mark all the columns specified and 2 marks for the start date condition

    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_dateFROM needs

    WHERE start_date