UNIVERSITY OF WASHINGTON

CSE 594: DATABASE MANAGEMENT SYSTEMS

AUTUMN 1999

Homework 6: Object Databases

See the web page for homework guidelines, due dates, and policies. Note that this assignment will not be accepted after the due date (beginning of class on Wed. Dec. 8) for any reason. Also, there is no need to use O2 to answer any of the following.

  1. (50 points) Consider a database with two entities: Employee (name, age, salary) and Department (name, city). There are two relationships: Every department has exactly one Employee who manages the Department, and every employee manages at most one department (one-to-one relationship); and every Employee works for exactly one Department (many-to-one relationship).

    1. Draw an E/R diagram for this database. You do not need to indicate primary keys, but you may do so if you wish.
    2. Write O2 class definitions for this database. Do not use any collection types in the fields of your tuple types. Don't worry about getting the syntax perfect, and do not include any methods..
    3. Write a different set of O2 class definitions for this database. This time you must use exactly one collection type in one of your fields and you should be careful not to store any information redundantly. Again, don't worry about perfect syntax and don't include any methods.
    4. List the advantages and disadvantages of each approach. Consider issues such as expected queries, ease of implementing methods that might be needed, managing constraints, etc.

  2. (50 points) Consider the following O2 database, in which each named object is intended to be an extent for the corresponding type (and all its subtypes):

    class Ship inherit Object public type
    tuple (name: string,
    displacement: integer,
    crewsize: integer)
    end;

    class GunShip inherit Ship public type
    tuple (num_guns: integer,
    bore: integer)
    end;

    class Carrier inherit Ship public type
    tuple (deck_length: integer,
    escorts: unique set (Ship))
    end;

    class Submarine inherit Ship public type
    tuple (max_depth: integer)
    end;

    class BattleCarrier inherit Carrier, GunShip public
    end;

    name AllShips: unique set (Ship);
    name BCs: unique set (BattleCarrier);
    name Carriers: unique set (Carrier);
    name GunShips: unique set (GunShip);
    name Subs: unique set (Submarine);

    Write the following queries in OQL:

    1. Retrieve all submarines.
    2. Retrieve a set containing all escorts (use "flatten").
    3. Print the name and decklength of all aircraft carriers that have an escort with the same name as the carrier.
    4. Print the names of all ships that are not submarines.