Homework 3

Due Date: November 9, 2009
Points: 50

1) Create a UML model drawing using any graphical tool that you like, similar to the
example we discussed in the lecture.  That means:

a) Organize the following classes in a class hierarchy.  No relationships. No
instances.
Remember that more general classes should be drawn above more specific classes.
Remember that siblings should be drawn approximately at the same height.

Electronic_Device, Cell_Phone, Telephone, Home_Phone, Music_Player, iPhone,
Computer, Lap_Top, Desk_Top, Portable_Music_Player, Television, CD_Player,
Protable_CD_Player, Portable_Device.

Note that an iPhone is both a cell phone and a music player, a laptop is both
a computer and portable device, etc.  There are probably two or more solutions
that make sense, not just one.  So don't look desperately for the one correct
solution.

b) Draw any three attributes you like (three for the whole diagram, NOT for each class).
But make sure that you put the attributes at the
right places. Not too hight, not too low in the hierarchy.
Remember that attributes are inherited down.
Remember that attributes should have simple data types (number, string, date).

The attributes are simply ADDED to the diagram from question
a).

You may make a simple Word drawing, or you may use NetBeans IDE, or whatever
else you have access to.  Just NO hand drawing.

There is no programming here.  Just drawing.  [10 points]


2) In this question we will reuse the table POPULATION2006 from Homework 1.
You notice that this table has three columns.

a) Store the information from POPULATON2006 in a new table OO_POPULATION2006.
The table OO_POPULATION2006 should have ONE COLUMN ONLY, which should be
of an object type.

Write a cursor-based program to insert all data into  OO_POPULATION2006.
No other method is permitted.
The data is taken from POPULATION2006, of course.

[5 points]

b) Using your new table OO_POPULATION2006 write a program using a cursor
which will print to the screen all countries and their ranks and populations.
One country per line. From the biggest to the smallest.
After each line of output for a country, your program should
draw a horizontal line of minus signs like this.
-------------------------------------------------

NOW... the length of that line should be the NATURAL LOGARITHM
of the population of this country, multiplied by 3.

[5 points]

3) a)
Store the information from POPULATON2006 in a new table XL_POPULATION2006.
The table XL_POPULATION2006 should have ONE COLUMN ONLY, which should be
of XML type.

Every row should contain the information of one country, stored as follows.
This is an example, of course.

<country>
<rank>1</rank>
<name>China</name>
<population>1313973713</population>
</country>

Write a cursor-based program to insert data into  XL_POPULATION2006.
No other method is permitted.
The data is taken from POPULATION2006, of course.

[5 points]

b) Redo problem 2)b) for the table XL_POPULATION2006.
Remember to use a cursor.

[5 points]

4) Create a table COUNTRY_CONTINENT with two columns, 
COUNTRY and CONTINENT.
The data for this table can be found here:
http://en.wikipedia.org/wiki/List_of_countries_by_continent_(data_file)

Do as much cleanup as you can in the editor.
Throw out all the "Kingdom..." etc. in the editor.
Try to make the country names look like those in POPULATION2006
before you even load the data into the table.
Correct names that are obviously different in the two tables.

You may use Oracle update statments,
or you may clean up problems in the editor before loading.
Whatever is easier for you.

As usual, as always, SHOW THE TABLE.

[10 points]

5) Add a column CONTINENT to the original table POPULATION2006.
For every country in your table, fill in the correct continent.

Allowable continents are

    * AF = Africa
    * AS = Asia
    * EU = Europe
    * NA = North America
    * SA = South America
    * OC = Oceania
    * AN = Antarctica

This should be done by a PL/SQL program.
Here is an outline how to do it:

- Loop with a cursor over all countries in POPULATION2006.
- For every country, find it with a second cursor in COUNTRY_CONTINENT
  and extract the correct continent.  
- If there is no such country, give an error message that contains the name of the country.
- Then update the line in POPULATION2006 with the correct continent.
- Use the full name of the continent in POPULATION2006, NOT the 2 letter abbreviation.

SHOW THE PROGRAM.
SHOW THE TABLE.  
But you knew this, right?

[10 points]

Yes, I know most of this can be done with a Join.
But the point is to exercise programming.





THE FOLLOWING APPLIES TO ALL ASSIGNMENTS:


- Create a nice cover page with 
  your name, assignment number, class number and a descriptive
  title of the assignment.
  
  All parts of your assignment need to be stapled 
  together, or held together by a folder.  Points will be taken off
  for not complying with these rules.

  No handwriting anywhere.
  No handwriting anywhere.
  No handwriting anywhere.

  Make things look nice and professional.  

- Documentation:
  Do a reasonable amount of internal documentation.
  Internal documentation typically means that you explain
  your code or SQL statements.
  No external documentation unless I specifically ask for it.

- Test runs:
  Show your table after you build it.  Show testruns.
  Show as much as you can.  The burden of proof is up to you.
  NO TESTRUNS, NO POINTS. 
  (Or very, very few.)  You may record the results in a file.
  Thus, you don't need to do screen dumps.
  You will not be punished for too many test runs.

- Hardcopy:
  All code, documentation, and testruns will be accepted as Hardcopy
  (Printout) ONLY.  No email, No fax etc.

- Grading:
  Grading takes into account correctness of the results, but also
  how well they are documented, and what their visual appearance is.
  Things should look nice and PROFESSIONAL.  Not sloppy.  Use a spelling
  corrector for your comments or (later on) write-ups.  Some people do this
  very nicely.  Don't cut corners here, or you will look bad in comparison.

- Cheating:
  The usual policies apply.  0 points for "suspiciously similar" results.
  Report to the Dean in case of repetition.

- Files:
  You must keep all your files of every assignment up to the end of
  the semester.  If there is any doubt about your assignment I will
  ask you to demonstrate it online.

- Late policy:
  I will take off 10 points for being late up to 1 week.  Programs
  that are handed in more than a week late will receive no credit
  at all, unless you have a good reason with WRITTEN documentation
  (usually medical).