Example: Sales

 

Suppose that you want to define tables to keep your company's sales in different countries.

You create the tables as follows:

     CREATE TABLE US_SALES 
       (PRODUCT_ITEM  INTEGER, 
        MONTH         INTEGER CHECK (MONTH BETWEEN 1 AND 12), 
        YEAR          INTEGER CHECK (YEAR > 1985), 
        TOTAL         US_DOLLAR) 
      
     CREATE TABLE CANADIAN_SALES 
       (PRODUCT_ITEM  INTEGER, 
        MONTH         INTEGER CHECK (MONTH BETWEEN 1 AND 12), 
        YEAR          INTEGER CHECK (YEAR > 1985), 
        TOTAL         CANADIAN_DOLLAR) 
     
     CREATE TABLE GERMAN_SALES        (PRODUCT_ITEM  INTEGER, 
        MONTH         INTEGER CHECK (MONTH BETWEEN 1 AND 12), 
        YEAR          INTEGER CHECK (YEAR > 1985), 
        TOTAL         EURO)

The UDTs in the preceding examples are created with the same CREATE DISTINCT TYPE statements in Example: Money. Note that the preceding examples use check constraints.

 

Parent topic:

Defining tables with UDTs