5

i need advice, is this a good database structure? this is a comments table with foreign keys to users and posts table. the post_id and user_id can be repeated a lot of times so i wondered if i missed something here. i kinda forgot the 1/2/3 normalized form rules, so can someone give me a quick refresh? is this current structure good or should i change it?

Comments
  • 3
    That looks okay to me. It’s a simple structure so doesn’t need any further normalisation in my opinion. I’m sure data structure people will disagree though.
  • 0
    I'm not too much of a data systems expert but your setup looks sound. It's very similar to a SQL database I'm building. 😉
  • 1
    You’re probably gonna want a date as well but otherwise it seems fine to me. You could optionally offload post to its own table and reference it with a foreign key, so you could share the same body table as posts.
  • 0
    I'd just put the comment id, userid and post id (with foreign keys) in one table, then add a relation to a table that has the comment id and the comment body.
Add Comment