Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Constraint problem: number of rows...
On Mon, 13 Jun 2005 19:38:37 +0200, Volker Hetzer interested us by
writing:
> I've got a rather stupid constraint problem:
> There's a table with data on PCB symbols (like "7400" or "Resistor").
> Per symbol there's the number of pins on the symbol.
> Now, another table is supposed to have as many rows (per symbol)
> as there are pins.
> Is there any way I can have a constraint checking this?
AFAIK, a simple database constraint will not cover this. Heck, it doesn't even cover comparisons between tables. (From 9i SQL Ref manual: "The condition of a check constraint can refer to any column in the table, but it cannot refer to columns of other tables.)
Do you need an external table, or could the other be a nested table or varray? If external, I suspect it's time to start looking at the triggers.
I've run into this several times and solved it both the above ways (triggers and varrays). Looking forward to seeing other responses!
It would be nice if 'Foreign Key' constraint lifted the 'match' restriction and allowed 'expression' instead. Then we could write
CONSTRAINT match_and_range
FOREIGN KEY (mycol, myref) REFERENCES reftab (mycol=fcol, myref<=fref); -- Hans ForbrichCanada-wide Oracle training and consulting mailto: Fuzzy.GreyBeard_at_gmail.com
![]() |
![]() |