Sybase Adaptive Server IQ 12.4.2 Administration And Performance Manual page 146

Table of Contents

Advertisement

Working with tables
Creating unenforced
foreign keys
Creating an
unenforced foreign
key in Sybase Central
126
For more information, see the Sybase Central online Help.
Note
Multi-column primary keys are not enforced, and require the keyword
. Primary key column order is based on the order of the columns
UNENFORCED
during table creation. It is not based on the order of the columns as specified in
the primary key declaration.
You can create a table named
employee's skill level for each skill in which they are qualified, as follows:
CREATE TABLE emp_skill(
emp_id INTEGER NOT NULL,
skill_id INTEGER NOT NULL,
"skill level" INTEGER NOT NULL,
PRIMARY KEY( emp_id, skill_id ) UNENFORCED,
FOREIGN KEY REFERENCES employee UNENFORCED,
FOREIGN KEY REFERENCES skill UNENFORCED
)
The
table definition has a primary key that consists of two columns:
emp_skill
the
column and the
emp_id
one skill, and so appear in several rows, and several employees may possess a
given skill, so that the
skill_id
The
table also has two foreign keys. The foreign key entries indicate
emp_skill
that the
column must contain a valid employee number from the
emp_id
table, and that the
employee
table.
A table can only have one primary key defined, but it may have as many
foreign keys as necessary.
Note
Adaptive Server IQ does not enforce foreign keys or multi-column
primary keys. You must specify the keyword
delete these constraints. They can be useful, nonetheless, because they provide
information that Adaptive Server IQ uses to optimize queries, and to define the
underlying relationship between joined columns.
For more information about valid strings and identifiers, see the chapter "SQL
Language Elements" in the Adaptive Server IQ Reference Manual.
Each foreign key relationship relates a primary key in one column to a column
in another table, which becomes the foreign key.
, which holds a description of each
emp_skill
column. An employee may have more than
skill_id
may appear several times.
must contain a valid entry from the
skill_id
UNENFORCED
skill
when you add or

Advertisement

Table of Contents
loading

Table of Contents