Using join indexes

Example

In the sample database used throughout this book, the sales_order table

 

contains three foreign keys, each of which is related to the primary key of

 

another table.

You can create this table using the following commands:

CREATE TABLE "DBA"."sales_order"(

(

"id"

integer NOT NULL,

"cust_id"

integer NOT NULL

REFERENCES "DBA"."customer"

("id")

UNENFORCED,

 

 

"order_date"

datetime NOT

NULL,

"fin_code_id"

char(2) NULL

 

REFERENCES "DBA"."fin_code"

("code")

UNENFORCED,

 

 

"region"

char(7) NULL,

 

"sales_rep"

integer NOT NULL

REFERENCES "DBA"."employee"

("emp_id")

UNENFORCED,

 

 

PRIMARY KEY ("id"),

 

);

 

 

As shown in the figure, the sales_order table is at the center of the star join. Each of its foreign key columns can contain many instances of the primary key it refers to. For example, if you enter:

166

Page 186
Image 186
Sybase 12.4.2 manual Another table, You can create this table using the following commands, 166