Scenario:
- I have a simple text-based post. Which can receive
comments
andlikes
. All entities have their own tables. - Like and comment generate
notifications
.
Basic Parent-Child RelationShip in database (RDBMS):
Current Approach:
When I have to delete post, I delete comments, likes and their notifications too.
Because:
- 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.
Question:
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 status
to DELETED
with deleted time. To keep it for few days, then permanently delete using job.
status
toDELETED
. I should've mentioned it earlier..