I use cascading deletes as per business rule. For example, my customer record has multiple orders and each order can have multiple shipments and multiple payments. My business rule is not to erase a customer with orders, but orders should be erased even if they have shipments or payments. The business logic behind this was that we want to make it a hassle to erase a customer. On the other hand, erasing an order that has shipments or payments is done very regularly, because shipment and payment records are added before they actually happen (planned shipment and payments), so order records are erased when the order isn't finalized. The business rule was to make it less of a hassle. Sim David wrote: > Hi there. > > When is a good time to use cascading deletes? > > Usually, for safety reasons, I prefer to not ever use cascading > deletes. But that can lead to some complex code that uses topological > sorts etc to manually delete records in the right order, when a > cascading delete is needed. > I don't know, maybe I have the wrong mindset, and cascading is > preferable (in terms of object model) in some cases? I'd like to read > more on this subject (general best practices for what types of > cascading are appropriate to use when). > > Any tips? > > Thanks, > > David. > -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general