| From: | Joel Burton <jburton(at)scw(dot)org> |
|---|---|
| To: | Christian Marschalek <cm(at)chello(dot)at> |
| Cc: | "'Bruce Richardson'" <pgsql(at)itsbruce(dot)uklinux(dot)net>, "[GENERAL] PostgreSQL" <pgsql-general(at)postgresql(dot)org> |
| Subject: | RE: Unique or Primary Key? |
| Date: | 2001-05-03 20:49:46 |
| Message-ID: | Pine.LNX.4.21.0105031648200.8245-100000@olympus.scw.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
> > Besides, I couldn't see much use in creating it as a primary
> > key. How
> > would I ever reference it from another table?
If you're questioning how to use a multi-field primary key, it's easy...
create table p (id1 int not null, id2 int not null, primary key(id1,
id2));
create table c (id1 int, id2 int, foreign key (id1, id2) references p);
insert into p values (1,2);
insert into c values (1,1);
insert into c values (1,0);
ERROR: <unnamed> referential integrity violation - key referenced from c
not found in p
--
Joel Burton <jburton(at)scw(dot)org>
Director of Information Systems, Support Center of Washington
| From | Date | Subject | |
|---|---|---|---|
| Next Message | GH | 2001-05-03 21:03:18 | Re: Ideal hardware configuration for pgsql/Netra |
| Previous Message | Michelle Murrain | 2001-05-03 20:49:15 | Re: DBD::Pg errstr method doesn't return full error messages |