Re: super type & sub type

From: Malte Finsterwalder <finsterwalder02_at_web.de>
Date: Fri, 08 Nov 2002 19:18:54 GMT
Message-ID: <3dcc0ae7.89171652_at_news.compuserve.de>


On 8 Nov 2002 09:54:45 -0800, Yasaswi Pulavarti wrote:

>finsterwalder02_at_web.de (Malte Finsterwalder) wrote in message news:<3dcab06f.476004_at_news.compuserve.de>...
>> On 5 Nov 2002 13:20:51 -0800, Yasaswi Pulavarti wrote:
>>
>> >I have successfully created a super type and 4 subtypes. How do I
>> >populate the tables with my application? Do I just ignore the super
>> >type table and populate the sub type tables? Let me know.
>>
>> Are you talking about SQL-99 user defined data types in the database?
>> And of SQL-99 table hierarchies?
>>
>> Or are you talking about super-/subtypes in your OO programming
>> languages and a mapping to pure relational structures with SQL-92?
>>
>> I'm asking, because SQL-99 supports super-/subtypes and multiple
>> tables inside a hierarchie automatically, while in a SQL-92-Database
>> you will have to keep track if the hierarchie yourself.
>>
>> Greetings,
>> Malte
>
>Malte:
>I was talking about the sub-type, super-type in the database. I got
>the answer to my question. I use MySQL 3.23.51 server. I am not sure
>if the database is SQL-92 or SQL-99 compliant. Inform me if you know.

I have no information about MySQL.

A SQL-99 compliant database allows to use create type statements, like:

CREATE TYPE Person_t AS (name VARCHAR(100), age INTEGER)

Then you can also create a sub-type:

CREATE TYPE Employee_t UNDER Person_t AS (company VARCHAR(100))

Now you can create typed tables and include them in a hierarchie:

CREATE TABLE Persons OF Person_t
CREATE TABLE Employees OF Empolee_t UNDER Persons

From now on, when you insert Employees into the Employees table, they are also shown in the Persons-table.

SELECT * FROM Persons

shows you name and age of all persons including of all employees in the employees table.

But I really don't know if MySQL supports this.

Greetings,

   Malte Received on Fri Nov 08 2002 - 20:18:54 CET

Original text of this message