> What i call the Secondary key is when i want two or more fields
> key eg. Order Table can be more than one or more transaction, i
> order no. and record no. as key. The Order no. call primary key and
> Record no. as secondary key.
I'm afraid that's incorrect. What you have is a "two-column primary
key." There is no "secondary key". Here's how you create one:
create table order_detail (
order_no INT NOT NULL REFERENCES orders(order_no),
record_no INT NOT NULL,
item_no INT NOT NULL REFERENCES inventory(item_no),
quantity NUMERIC NOT NULL,
CONSTRAINT order_detail_PK PRIMARY KEY (order_no, record_no)
Got it? Read the "CREATE TABLE" documentation for more detail.
P.S. To reiterate: There are Primary Keys, Candidate Keys, Surrogate
Keys, and Foreign Keys, but no "Secondary Keys".
pgsql-novice by date
|Next:||From: cristi||Date: 2002-10-24 05:03:13|
|Subject: display functions|
|Previous:||From: Josh Berkus||Date: 2002-10-24 00:07:50|
|Subject: Re: [BUGS] Optimization disaster|