Are Foreign Keys ALWAYS a good idea? #FK
So I'm in love with how easy it is to add and define foreign key constraints within Laravel. My question is not about how to do them as much as it is - should I always be adding them - or just salt/peppering them where I'm okay with permanent data loss due to cascading deletes?
While I get all of the benefits of cascading deletes I've read online that cascading deletes aren't always wanted in some applications (like e-commerce sites). I build a lot of learning-based sites where content is reusable and the thought of such easy and permanent data destruction freaks me out.
For example,
In a user based site, I can see the benefit in having all comments for a post deleted when the post is deleted so they aren't orphaned. But what about users and my access logs? If a user's account is deleted, and I've set up the foreign key on the access log, and those get deleted I may be loosing data I want later. Especially if I need to restore the user.
Should I serialize and store records in some sort of log before performing the deletes so I can restore it later if needed?
Please or to participate in this conversation.