Sybase Adaptive Server IQ 12.4.2 Administration And Performance Manual page 180

Table of Contents

Advertisement

Using join indexes
Using foreign references
Examples of join relationships in table definitions
160
Adaptive Server IQ uses foreign keys to define the relationships among
columns that will be used in join indexes, and to optimize queries. However,
Adaptive Server IQ does not enforce foreign key constraints. For this reason,
when you specify a primary key-foreign key relationship, you must include the
keyword.
UNENFORCED
Adaptive Server IQ does not support key join indexes based on multicolumn
foreign keys.
The following example shows how you specify the join relationship by means
of primary and foreign keys. In this case, one customer can have many sales
orders, so there is a one-to-many relationship between the
table (its primary key) and the
customer
table. Therefore, you designate
references the
column of the
id
The first example creates the
key. To simplify the example, other columns are represented here by ellipses
(...).
CREATE TABLE DBA.customer
( id integer NOT NULL,
...
PRIMARY KEY (id),)
Then you create the
sales_order
named
as the primary key. You also need to add a foreign key relating the
id
column of the
cust_id
sales_order
You can add the foreign key either when you create the table or later. This
example adds the foreign key by including the
column constraint in the
CREATE TABLE DBA.sales_order
(id integer NOT NULL,
cust_id integer NOT NULL
REFERENCES DBA.customer(id) UNENFORCED,
order_date date NOT NULL,
fin-code-id char(2),
region char(7),
sales_rep integer NOT NULL,
PRIMARY KEY (id),)
column of the
cust_id
in
cust_id
sales_order
table.
customer
table, with the column
customer
table with six columns, specifying the column
table to the
column of the
id
REFERENCES
statement.
CREATE TABLE
column of the
id
sales_order
as a
that
FOREIGN KEY
as its primary
id
table.
customer
clause as a

Advertisement

Table of Contents
loading

Table of Contents