I am trying to model a DB in Postgresql after a social media platform such as twitter and Instagram.
I have the following requirements:
- A user can create a Post
- A User can Like a Post
- A user can comment on a Post
- A user can comment on another users comment (Reply to a comment)
- A user can like a comment
Now I am aware that we can have deeply nested comments if users keep replying to other users in the form of comments. I came up with a a few self-referencing tables that all inherit from a common Entity table. Here is my implemntation so far:
^^ I am aware that it is possible to "like" another persons "Like" or comment on a "Like" which is not a requirement. To prevent this I am thinking I can enforce these constraints at the application code level. Its always better to leave options open incase we might want to implement them in the future right?
My Question is, is this a good DB implementation? Are there use cases and pitfalls I might run into that I am not seeing? Does the design fit the use cases?