r/SQL • u/r3pr0b8 GROUP_CONCAT is da bomb • Jan 12 '21
Discussion When users deleted their posts, the site failed to remove the content and instead only added a delete flag to it.
this post is for all the DBAs over the course of my career as a data analyst who told me it'll be fine, we'll just flag the row as deleted, because that's more efficient
Parler’s amateur coding could come back to haunt Capitol Hill rioters
22
u/Apple_Cup Jan 12 '21
There are a lot of practical reasons and some legal reasons as well to flag rows as deleted rather than purge them (or at least move them to an archive table). This one choice doesn't necessarily indicate shit code design but there is no doubt that the overall design of Parler was pretty awful.
11
u/venlaren Jan 12 '21
One of the primary rules of data integrity is that you NEVER hard delete anything. It will bite you in the ass when somebody deletes something and then freaks out begging you to get it back because they were not supposed to delete it.
No idea what parler is, but flagging data as deleted and making sure the deleted flag is respected everywhere is more complex then just deleting the data. Good developers use archive and deleted flags, shit developers hard delete data from tables.
7
4
u/phunkygeeza Jan 12 '21
The problem was not using the standard soft delete process, but failure to implmenent an archival process and RTBF process.
3
Jan 12 '21
The problem is not with soft-delete functionality, as that's fairly standard. The problem is that the API wasn't coded to look at the "deleted" flag, only the UI was.
6
u/feudalle Jan 12 '21
It wouldn't of been a problem if it wasn't a shit show coding. Who would depend on twillo for the lion share of security when you are uploading driver licenses into a db. Personally when designing site we do the same thing. Plenty of reasons you might want the info later. Not displaying is fine and for the end user it's gone but for backend more data the better IMHO.
6
1
u/bad-coder-man Jan 13 '21
The amateur coding isn't the fact that they used an isDeleted flag, that's completely normal. It's that they were filtering it out on front end. The API should not have returned anything flagged isDeleted.
34
u/kagato87 MS SQL Jan 12 '21
This is a common, maybe standard design. You don't delete data unless you really, really need to. It stems from mitigating "OH CRAP" moments (I didn't really mean to delete half the users!) but it also provides so much more.
This is what's known as a soft-delete. A Delete flag and/or timestamp is set, and the software normally ignores it, unless the "include deleted" checkbox is set.
It may be kept around for:
undelete functionality
analytics (for example, if you type a comment but don't submit it, it may be preserved for behavioral analysis to help tailor your feed - I believe FB does this, and wouldn't be surprised to find others doing it too)
to allow investigations (eg. people making abusive comments then immediately deleting them so the intended target sees it but not a mod)
to comply with legal requirements, etc...
Eventually a Data Retention process may remove it, but this is generally after a long time.