Subject Re: [firebird-support] get foreign key
> hi all, i have this project to build a crm application. my sales order
> table has a foreign key referenced to the customer table. my problem
> is that, everytime i try to delete a customer record, i got this
> "foreign key" exception. how do i know that this customer record is
> not referenced to the sales order record before the user press the
> delete button?
> i use firebird 2 and delphi 7
> any comments will be highly appreciated
> thanks
> rey

You might want to consider a different approach. Often, organizations
need to retain all their records for some period of time. Deleting a
customer record usually means also deleting all transaction records for
that customer as well. This can cause sales and tax reports to change,
since the records of transactions vanish from the database.

So, many companies do not actually delete a customer's record like that.
Instead, they have a flag in the record that specifies whether the
customer is an "active" customer or not. When the user tries to "delete"
a customer, the software simply marks the customer "inactive" or
"deleted", which causes their information to not show up on active
customer lists, etc., but doesn't actually delete any information from the
database. Actual deletion is deferred until the record retention period
has elapsed, after which the customer record, and all dependent records,
can be really deleted.