SQL3 (Cont.)


Value and Object Types
(Object-type example)
  • Methods observer and mutator are for querying and modifying an attribute value.
  • A constructor function serves to create or initialize values.
CREATE VALUE TYPE address
  street  VARCHAR(25),
  city    VARCHAR(25) );

CREATE OBJECT TYPE person (
  name     VARCHAR(30),
  age      INT,
  domicle  address );

CREATE OBJECT TYPE employee UNDER person (
  qualification  VARCHAR(30),
  salary         DECIMAL(7,2),
  familymembers  SET(person) );

CREATE TABLE company (
  name          VARCHAR(30),
  headoffice    address,
  subsidiaries  SET( VARCHAR(30) ),
  president     employee );
Subtables
Declare tables as subtables of already existing ones. Tables in SQL3 can be more than just sets of tuples. A table can be a Every tuple within a table can be equipped with a unique row identifier.

(Row-identifier example)
CREATE TABLE person WITH IDENTITY (
  name      VARCHAR(30),
  age       INT,
  domicile  address,
  partner   person IDENTITY );