Help Needed with nested Comment Schema
Hey frens. I'm building a stack overflow clone for poultry farmers.
For a commenting system, how should I go about modeling comments, and their replies?
I watched a great tutorial by MonsterLessons Academy. https://www.youtube.com/watch?v=sjAeLwuezxo
Oleksandr doesn't distinguish between comments and replies, but just adds a "parentId " field, which is null if it is just a regular comment.
But when I look at a particular reply from a facebook thread, they provide a reply_comment_id . Which makes me think they have a more intricate model. For additional context, facebook stops after replies-to-replies. www.facebook.com/ groups/123456789/ posts/1234567890/ ? comment_id=123412341234 & reply_comment_id=123456789012345 Should I ... (A) treat all comments the same (whether they're nested or not) and simply add a field to distinguish it as a child ? (B) Or should I add another table just for replies ? I'm sure there's a trade-off for simplicity, scaling, performance etc. ?
But when I look at a particular reply from a facebook thread, they provide a reply_comment_id . Which makes me think they have a more intricate model. For additional context, facebook stops after replies-to-replies. www.facebook.com/ groups/123456789/ posts/1234567890/ ? comment_id=123412341234 & reply_comment_id=123456789012345 Should I ... (A) treat all comments the same (whether they're nested or not) and simply add a field to distinguish it as a child ? (B) Or should I add another table just for replies ? I'm sure there's a trade-off for simplicity, scaling, performance etc. ?
9 Replies
Have a think about data access patterns
Ie read vs write scalabaility
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Recommend any search terms for a good article?
Medium
Data Modeling — Designing Facebook style “comments” with SQL
Let’s agree , we all have used the “comments” section of some or the other social networking site.
@pacifistbunny
This is what you meant by path?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Obviously I have some reading to do.
But would that be something super-difficult to refactor down the road?
What do you even call that concept? When you want to change your data schemas/structures for a large existing database / project ?
That's the third option this article recommends. 🙏🏼
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View