Pergunta

I have this big database on mysql (104 tables), where almost every single table has a FK pointing to a single table, like the master table.

There a huge web of relationships, and when I need to delete a record from the 'master' table, obviosly, there a lot of errors because of the relationships. All of them are set to 'Do nothing' on delete, so my question is, really, how safe is to change them (the relatioships) to delete on cascade instead of delete 'by hand' every single record on all of the tables affected?

I'm usyng MySql, last version (don't remmember exactly which one), and, if it works, PHP 5.2 and codeigniter.

Thanks a lot

Foi útil?

Solução

It's all about businessrules.

If it is in your businessrules that a cascade delete should happen, I don't see why you program it by hand?

Of course, when programming by hand you can built in extra validations, but If you are not, deleting by hand only make thins more error-prone.

For one thing, when deleting 'by built in cascade' , the transaction is for free, you don't risk to leave orphans.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top