What is the best constraint to use on a forum table where users leave comments?
Assuming some users will be deleted at a later stage. if i delete a user who has commented, what happens to the users entry in the table?
Hope someone can explain.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are two parts to this question:
how best to implement this? You can “soft-delete” user rows. This has the advantages of:
Soft-deleting can be implemented by adding another column to the users table, with a
dateDeletedcolumn — if it’s Null, then the user isn’t deleted. I believe SO uses such a mechanism for deleting posts.what does
restrict cascade no actiondo? The MySQL docs sayIn other words, if you use this, you won’t be able delete rows if doing so would break referential integrity.