pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedColumn References
2+ messages / 2 participants
[nested] [flat]
* Column References
@ 2003-10-31 19:44 Epps, Aaron M. <Epps.Aaron@mayo.edu>
2003-11-01 17:20 ` Re: Column References Bruno Wolff III <bruno@wolff.to>
0 siblings, 1 reply; 2+ messages in thread
From: Epps, Aaron M. @ 2003-10-31 19:44 UTC (permalink / raw)
To: pgsql-admin
I've got a question about references, is it possible to specify criteria for the Reference. For example, Table 1 has Field1 That References Field1 in Table2, However I only want Field 1 in Table 1 to reference the Records in Table2 that have the Valid Field set to TRUE. In other words, I don't want the user to be able to enter invalid records from table 2 into field 1 in table 1. Is there a different way of accomplishing the same thing?
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Column References
2003-10-31 19:44 Column References Epps, Aaron M. <Epps.Aaron@mayo.edu>
@ 2003-11-01 17:20 ` Bruno Wolff III <bruno@wolff.to>
0 siblings, 0 replies; 2+ messages in thread
From: Bruno Wolff III @ 2003-11-01 17:20 UTC (permalink / raw)
To: Epps, Aaron M. <Epps.Aaron@mayo.edu>; +Cc: pgsql-admin
On Fri, Oct 31, 2003 at 13:44:40 -0600,
"Epps, Aaron M." <Epps.Aaron@mayo.edu> wrote:
> I've got a question about references, is it possible to specify criteria for the Reference. For example, Table 1 has Field1 That References Field1 in Table2, However I only want Field 1 in Table 1 to reference the Records in Table2 that have the Valid Field set to TRUE. In other words, I don't want the user to be able to enter invalid records from table 2 into field 1 in table 1. Is there a different way of accomplishing the same thing?
The way I have done this is to use redundant data in table1. For example in
your case you might include a Valid field in table 1 with a constraint
forcing it to always be true. Then you can use a two column foreign key
reference from table 1 to table 2 that will enforce your constraint.
(You will also need to make a unique index on the two column combination
in table2.)
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-11-01 17:20 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-10-31 19:44 Column References Epps, Aaron M. <Epps.Aaron@mayo.edu>
2003-11-01 17:20 ` Bruno Wolff III <bruno@wolff.to>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox