views:

74

answers:

1

Say I have a Employees table (PK is employeeID) and a sales table, where the sales table has a FK column for employeeID.

Now when designing my deleteEmployee stored procedure, should I first delete rows in the Sales table or should I create seperate stored procedures to delete in each table, and then worry about that in my business logic layer?

+2  A: 

No, no, no.

Add a field to the Employee table called "OutServiceDt" and store the date they left your company.

That way you keep the records of the sales they made, their address information, and whatever else you've got :)

If you're looking for employes who are in service, filter on "OutServiceDt is null".

Andomar
We often use the approach of "never delete anything" - if it was good enough to put in the database, it probably has value still being there.
Neil Trodden
Seconded. Losing historical records is generally a bad idea, so I would design some way of keeping track if the employees are active or not so you business logic layer can use that information, but all the old information is still intact.
ghills