Home > database >  PostgreSql describe tables for a forum
PostgreSql describe tables for a forum

Time:04-07

I'm building a forum. Here is how I want the setup:

enter image description here

My problem is that I'm using SERIAL PK for my Id's. I don't know if that's the best option for production but my Topics should be able to link to both Forum or Subforum as I don't want to create 2 tables for each, also I would have to create 2 replies tables for each Topic table.

Would I need to create unique ids on all tables? Then I could link Topics and Replies to different tables? If so, how I would do that?

CodePudding user response:

diagram

I believe you need something like this. As mentioned by Marcodor - forum can also be a subforum. I just edited your diagram a little bit.

For instance if forum is a subforum parent_forum_id is set to it's parent forum, therefore if it is a parent forum parent_forum_id is set to null.

  • Related