- I have a simple text-based post. Which can receive
likes. All entities have their own tables.
- Like and comment generate
Basic Parent-Child RelationShip in database (RDBMS):
When I have to delete post, I delete comments, likes and their notifications too.
- when I fetch only notifications I don't have to check comment, like or post status to filter out deleted entity notifications.
- when I access a single comment (for edit or delete), I don't have to check post's status.
This approach helps me in GET data fast, but it makes deletion process slower. And because the use of transaction, it locks the table when there is too much activity on the post.
Should I stick to what I am doing currently? or I should try to delete fast, and perform checks on GET data? or any other approach?
PS: I am not actually deleting. I am soft deleting, means update a column named
DELETED with deleted time. To keep it for few days, then permanently delete using job.