SQL Server Business Logic: Deleting Reference Data

I am curious how some other people handled this.

Imagine a system in which there are only products, purchase orders and purchase order lines. Purchase orders are the parent-child relationship to the purchase order lines. Purchase order lines, refer to one product.

This works until you uninstall the product referenced by the purchase order line. Suddenly Line knows that he is selling something 30 ... but that does not know that.

What a good way to anticipate the removal of a data link part like this? I suppose you could just prohibit the removal of a product if any lines of purchase orders refer to it, but that sounds ... awkward. I assume that, most likely, you will save the purchase order in the database for many years, essentially welding the product you want to delete into your database.

+3
source share
3 answers

A parent should NEVER be deleted, or dependent lines no longer make sense unless you delete them. Although it’s “awkward” to display old records for users as valid choices, it is not inconvenient for your database to continue to make sense.

, "", "", , .

(, ), (, ), .

StartDate ExpiryDate , - (, ).

+4

. ,

, ( ).

, SQL Server , PurchaseOrder PurchaseOrderLines .

, .

( , ). , , , , . , , - ...

+3

, , , .

(POL) . , POL. , .. , PurchaseOrderLineOptions.

, . , - , , , .

, . .

For hits, you can leave the product identifier in the POL table for a link back, but you cannot depend on the product table to have any effect on the paid product ...

+2
source

Source: https://habr.com/ru/post/1766049/


All Articles