0

I'm really not sure if this is the right community to ask it in, but it seemed like it fits here.

But anyway, I'd like to know what's the usual approach of deleting a comment from database through website?

What I mean: when the user decides to delete his comment for example, does the comment actually get deleted from the database, or do developers create a column like deleted - int(1) default 0, where 0=not deleted, 1=deleted, and that column is being updated from 0 to 1 when a comment is being deleted? In this case, only comments where the deleted column is 0 would be displayed on the site.

Or is there no usual approach for this at all?

3
  • 1
    Both variants are possible. In most cases the comment is flagged - this method makes possible to restore the comment if it was deleted errorneously / uncorrectly.
    – Akina
    Commented Nov 11, 2019 at 12:36
  • In addition to @Akina s comment, it also makes it possible to do statistical analyses for how often comments are deleted, are there particular times when comments are deleted more often and so forth. Whether that is useful or not depends from system to system. Commented Nov 11, 2019 at 12:44
  • ... 3rd variant - copy to archive table, then delete from main table.
    – Akina
    Commented Nov 11, 2019 at 13:46

1 Answer 1

2

I'd say this depends on the set requirements - many projects demand that the database never forgets "things" - to be able to generate reports and so on. In these cases you usually have this deleted column already. On delete you update said column - and for the report-functions you have an additional table that keeps record of who "ordered the delete" (just in case "he" deleted something that wasn't meant to be forgotten).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.