Subject | Re: [firebird-support] very basic questions about FK |
---|---|
Author | Sergio H. Gonzalez |
Post date | 2009-10-14T14:30:53Z |
Thanks guys for the quick answer!! I use the FK just to check data integruty.
This is an example:
When I do an invoice, most of the items of the invoices are a reference to the
article's table (*) but some times the user can add a "free item" to the
invoice. It means: a line in the invoice that is entered by the user wich don't
point to an article. In that cases I set teh ID_article field to -999 and in the
article's table I have a record: ID_Article = -999 / Description = 'Free Item'.
That way I can use a FK to presererve data integrity. If I allow nulls in
ID_Article I could check for data integrity whith triggers... so... what should
I do?
-s
(*)I know that this is NOT very good, but I also copy the description of the
article in the invoice detail table... the problem is that the description of an
item may change and I don't want the invoice to change any of the descriptions)
This is an example:
When I do an invoice, most of the items of the invoices are a reference to the
article's table (*) but some times the user can add a "free item" to the
invoice. It means: a line in the invoice that is entered by the user wich don't
point to an article. In that cases I set teh ID_article field to -999 and in the
article's table I have a record: ID_Article = -999 / Description = 'Free Item'.
That way I can use a FK to presererve data integrity. If I allow nulls in
ID_Article I could check for data integrity whith triggers... so... what should
I do?
-s
(*)I know that this is NOT very good, but I also copy the description of the
article in the invoice detail table... the problem is that the description of an
item may change and I don't want the invoice to change any of the descriptions)