ERPNext database integrity

Hi guys,
A lot of thanks to you for a great system developed!

Can you please help me to understand how do you ensure database integrity in ERPNext for example when there is a deletion in a master child relationships? Doctypes tables doesn’t seem to be connected to each other through any foreign keys, so deleting a master is possible without deleting all childs which are related to it, right? Do you handle that on a app layer and delete childs manually each time when parent is deleted (or forbid parent deletion if there is any childs?). If so - is that always exectued in one transaction? Does that transaction started at ERPNext level (so custom coding each time for each transaction), or it is somewhere deep in Frappy - i.e. for example all db changes serving one HTTP request happen in one transaction automatically?

Can someone help me to understand that? I’m curios on how to ensure that ERPNext data is always stable and reliable and a bit confused with the code around these things.


Doctypes are linked. One can analyse the links by opening a Doc and than under menu select link to