Search code examples
sqloracle10gobject-relational-model

Properly populating tables in an Object Relational database


I've got a homework assignment that requires that I use Oracle 10g Express to implement an Object Relational database to track phone billing data. I have a superclass of Communications with subclasses of Call, Text, and Data. I'm hitting a snag with properly populating these tables so that I can find the appropriate data in the various tables.

My Types and Tables are declared as such:

create type CommunicationType as object (
  -- column names here
) not final;
create type CallType under CommunicationType (
  -- column names here
);
create type TextType under CommunicationType (
  -- column names here
);
create type DataType under CommunicationType (
  -- column names here
);
create table Communications of CommunicationType (
  -- Primary and Foreign key constraints here
);
create table Calls of CallType;
create table Texts of TextType;
create table Datas of DataType;

When I try to insert data into one of the subclasses, its entry doesn't appear in the superclass. Likewise if I insert into the superclass, it doesn't show up in the appropriate subclass. For example, insert into Calls values (CallType( -- Values -- )); doesn't show any data in Communications. Nor does insert into Communications values (CallType( -- Values -- )); show anything in Calls.

What am I doing wrong?


Solution

  • You have created four separate tables. If you insert a row into one table, there is no reason to expect to see your row in another table.

    Your tables based on CallType, TextType and DataType inherit their structure and behaviour from CommunicationType, but this doesn't mean that the data is replicated. I suspect you probably don't need the table Communications at all.

    < aside > Personally, if I'm using the Oracle database I'd forego using object types entirely and just model the thing using a pure Relational model, but that's probably just me - and doesn't help you much since your teacher seems to expect you to implement an "Object Relational" database... :)