[thelist] normalizing an abnormal table
rudy
r937 at interlog.com
Mon Oct 14 20:27:01 CDT 2002
>just add that field to Promotion_Items table as a FK
i think i should clarify
this has to be in conjuction with Promotion_ID
in other words, Promotion_ID *and* Is_Premier *together* have to be a
foreign key to the Promotions table
that way, the database ensures that premier promotion items are linked only
to premier promotions
now, theory says that FKs can only reference PKs, so this would dictate
that the pair of columns should be the PK of the Promotions table
that may be problematic, in that you could then have both promotion 1234
ordinary and promotion 1234 premier, but if the promotion id is an identity
or autonumber, this should not come up, and in any case, you can get around
it if you want
some databases will let you declare a foreign key on any column(s) of
another table, not just the pk, provided it/they are unique, so if you have
this option, use it
in any case, the bottom line is this: let the database handle the
structure, and don't sully your code with any of the constraint details
rudy
More information about the thelist
mailing list