From: | Jason Hihn <jhihn(at)paytimepayroll(dot)com> |
---|---|
To: | Richard Huxton <dev(at)archonet(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Help with array constraints |
Date: | 2003-04-03 15:50:32 |
Message-ID: | NGBBLHANMLKMHPDGJGAPKEGJCGAA.jhihn@paytimepayroll.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> >
> > What must I do?
>
> You might be able to add separate FK constraints (see CREATE
> TABLE or ALTER
> TABLE) for each array element.
>
> CREATE TABLE test (
> ...
> CONSTRAINT first_letter FOREIGN KEY (letter[0]) REFERENCES _test(id),
> CONSTRAINT first_letter FOREIGN KEY (letter[1]) REFERENCES _test(id),
> CONSTRAINT first_letter FOREIGN KEY (letter[2]) REFERENCES _test(id)
> )
>
> Don't know if that will work - I'm wary of using arrays myself. I'm a bit
> surprised that you can create a primary key on an array.
Whoops, that's not actually in my application!
> The other option is that you might need to alter your design.
> Either three
> separate fields or a separate table with (letter_index,
> char_value) so you
> only need the FK constraint on "char_value", and letter_index can be
> constrained with a CHECK.
Design altering is a BAD thing because I am attempting a port from a DBMS
that supports arrays, and they are used quite extensively in places.
Adjusting the schema would be to take a large hit, and the powers that be
are already weary about doing the port in the first place. Seeing this was
now supported a big joy for me, because it makes it so much easier.
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2003-04-03 16:06:40 | Re: Problem to add a delay to a date |
Previous Message | Tom Lane | 2003-04-03 15:36:31 | Re: unable to dump database, toast errors |