Reputation: 42
I am practicing in writing a simple forum and just can't decide on table structure. Currently I have this:
id int(11) AUTO_INCREMENT
title varchar(56)
group_id int(11)
group_parent tinyint(1)
access_from int(11)
alliance_forum tinyint(1)
alliance_id int(11)
alliance_role_access int(11)
Group parent is a 0 or 1 column which states wherever a forum is parent of forums, and group id is for group forums whch reffers to same table to record with group parent set to 1.
Alliance forum is same as group parent, as the alliance id, and access columns are for access control.
Which would be the best and perfomant way of restructuring this? Should I make 3 different tables for alliance forums, forum_groups and group_forums or keep it this way?
Upvotes: 1
Views: 414
Reputation: 612
I think you have the right idea but you're programming yourself into a corner right now.
Forums usually don't need nested threads, but nested groups/topics/categories
I would do it this way:
id int(11) AUTO_INCREMENT
name varchar(56)
parent int(11) #If parent is 0 there is no parent. Else it's the ID of the parent group (so you can have nested groups/topics/categories)
id int(11) AUTO_INCREMENT
title varchar(56)
alliance_id int(11) #again: 0 if not, else ID of your alliance
id int(11) AUTO_INCREMENT
thread int(11) # id of thread
message varchar(1000)
creator int(11) #user id of creator
You might also want to add things like timestamps and creator IPs to threads and posts.
If you want nested posts (reddit style), just add a parent int(11)
to the posts table
Not quite sure what access_from
is meant to be
Upvotes: 1