Hi guys!

sorry if there is already a thread on this but i couldnt see one...

I just want a little bit of help about the statement ON DELETE CASADE. I am designing the structures of my tables and I am not sure about using this statement. I know it means that if a record is deleted then it will also be deleted in every table in which it is referenced by a foreign key. But, i seem to using it in every table. Should this only be used in certain tables?

Thanks in advance.

Recommended Answers

All 2 Replies

depends on what you want to keep around.
if the data is not important for future reference, the delete cascade to your heart's content.

however, should data be valuable later, then those tables should not have rows automatically delete.

that is a "business process" decision on your or your management's part.

That should be defined in the time of table / relationship creation . If you wnat to delete all the child records by deleting the parent record thenu need specify ON DELETE CASCADE. Other wise it does not allow you to delete parent record if there is any sort of dependent child records.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.