I must link from one table to either of two tables X & Y. I can store
this link in columns:
REF_X_ID NULLABLE
REF_Y_ID NULLABLE
plus a constraint to ensure only one REF_*_ID is set for a row
OR
in columns:
REF_ID NOT NULL
WHICH_TABLE
i.e. store ID for both tables in only one column, and add an other
column that identifies which table REF_ID refers.
Which would be smarter idea considering table design, adding rows and
quering the table?On 23 Apr 2005 14:31:30 -0700, bbla32@.op.pl wrote:
>I must link from one table to either of two tables X & Y. I can store
>this link in columns:
>REF_X_ID NULLABLE
>REF_Y_ID NULLABLE
>plus a constraint to ensure only one REF_*_ID is set for a row
>OR
>in columns:
>REF_ID NOT NULL
>WHICH_TABLE
>i.e. store ID for both tables in only one column, and add an other
>column that identifies which table REF_ID refers.
>Which would be smarter idea considering table design, adding rows and
>quering the table?
Hi bbla32,
Since you can't use a FOREIGN KEY constraint on the latter and you can
use it on the former, I'd definitely favor the first version.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
Showing posts with label nullableref_y_id. Show all posts
Showing posts with label nullableref_y_id. Show all posts
Monday, March 12, 2012
Subscribe to:
Posts (Atom)