Jump to content

Foreign Key Overhead


hannibal

Recommended Posts

I know that foriegn keys are useful in that if I delete (i.e.) a Customer, all records in tables with his/her foreign key with On Delete (Cascade) will be deleted. Excellent from a maintenance point of view.

 

My question is what overhead on the (database) system is there by having foreign keys?

 

Thanks,

 

J.

 

I am using MySQL V5.

Link to comment
https://forums.phpfreaks.com/topic/92603-foreign-key-overhead/
Share on other sites

I have:

 

On Update = No Action

 

On Delete = Cascade

 

So that if a customer is deleted, the rest of the non-needed data in other tables is also removed as part of the housekeeping.

 

If a customers record is updated, none of the other tables require any action.

 

This saves me manually looping through other tables and deleting all records if a customer is deleted.

 

There is nothing wrong with this method is there? Seems logical to me... :)

 

Thanks,

 

J.

Link to comment
https://forums.phpfreaks.com/topic/92603-foreign-key-overhead/#findComment-474978
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.