Working with tables
126
For more information, see the Sybase Central online Help.
Note
Multi-column primary keys are not enforced, and require the keyword
UNENFORCED
. Primary key column order is based on the order of the columns
during table creation. It is not based on the order of the columns as specified in
the primary key declaration.
Creating unenforced
foreign keys
You can create a table named
emp_skill
, which holds a description of each
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
emp_skill
table definition has a primary key that consists of two columns:
the
emp_id
column and the
skill_id
column. An employee may have more than
one skill, and so appear in several rows, and several employees may possess a
given skill, so that the
skill_id
may appear several times.
The
emp_skill
table also has two foreign keys. The foreign key entries indicate
that the
emp_id
column must contain a valid employee number from the
employee
table, and that the
skill_id
must contain a valid entry from the
skill
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
UNENFORCED
when you add or
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.
Creating an
unenforced foreign
key in Sybase Central
Each foreign key relationship relates a primary key in one column to a column
in another table, which becomes the foreign key.
Summary of Contents for Adaptive Server IQ 12.4.2
Page 1: ...Administration and Performance Guide Adaptive Server IQ 12 4 2 ...
Page 16: ...xvi ...
Page 20: ...Related documents xx ...
Page 40: ...Compatibility with earlier versions 20 ...
Page 118: ...Troubleshooting startup shutdown and connections 98 ...
Page 248: ...Importing data by replication 228 ...
Page 306: ...Integrity rules in the system tables 286 ...
Page 334: ...Cursors in transactions 314 ...
Page 396: ...Users and permissions in the system tables 376 ...
Page 438: ...Determining your data backup and recovery strategy 418 ...
Page 484: ...Network performance 464 ...
Page 500: ...System utilities to monitor CPU use 480 ...
Page 514: ...Characteristics of Open Client and jConnect connections 494 ...
Page 536: ...Index 516 ...