Subject | Re: [firebird-support] Design Help |
---|---|
Author | unordained |
Post date | 2004-06-24T06:22:32Z |
Foreign keys are one of the easiest ways of setting up a constraint, to make sure your database
stays in a "sane" state (as determined by the designer.)
If you feel that invoice_details should always have a "valid" product id, which references an
actual product row, then yes (!) a foreign key is a very good thing. It's considered good practice
to let your database handle its own "sanity" checks, via constraints. This makes sure that no
matter who's messing with the data, through a trusted client application or not, everything stays
in good order.
It's not the only way to make sure everything stays squeaky-clean, but it's an easy and effective
one in most cases. On a side-note, adding a foreign key constraint automatically creates indices
for you, which might come in handy.
-Philip
---------- Original Message -----------
From: James <james_027@...>
To: firebird-support@yahoogroups.com
Sent: Thu, 24 Jun 2004 11:44:01 +0800
Subject: [firebird-support] Design Help
stays in a "sane" state (as determined by the designer.)
If you feel that invoice_details should always have a "valid" product id, which references an
actual product row, then yes (!) a foreign key is a very good thing. It's considered good practice
to let your database handle its own "sanity" checks, via constraints. This makes sure that no
matter who's messing with the data, through a trusted client application or not, everything stays
in good order.
It's not the only way to make sure everything stays squeaky-clean, but it's an easy and effective
one in most cases. On a side-note, adding a foreign key constraint automatically creates indices
for you, which might come in handy.
-Philip
---------- Original Message -----------
From: James <james_027@...>
To: firebird-support@yahoogroups.com
Sent: Thu, 24 Jun 2004 11:44:01 +0800
Subject: [firebird-support] Design Help
> I know setting up a foreign key between a two tables with master detail------- End of Original Message -------
> relationship is a good practice. I wonder if I have a lookup
> relationship is it good to set up a foreign key. An example of lookup
> relationship is ...
>
> a product table and a invoice_details table. When inserting a record in
> invoice_details, a list of product(less than 50 items) from the product
> table are available choices. I don't know if there's a need for setting
> up a foreign for this one, but my reason is to prevent a record from
> product table to be deleted when there is a record in invoice_details.
>
> Please advice.
>
> regards,
> james
>
> ------------------------ Yahoo! Groups Sponsor --------------------~-->
> Yahoo! Domains - Claim yours for only $14.70
> http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/67folB/TM
> --------------------------------------------------------------------~->
>
> Yahoo! Groups Links
>
>
>