You can see an example
what I figured out and used when I did my forum application.
It works alright.
The important TABLE for me here, is topics (threads).
We can say it acts as a glue between forums and posts tables.
Because 'topics' holds both forum_id and post_id value.
Where post_id is first post and subject is title of first post.
Then I have users table which is needed,
and an extra configs table, too.
The create sql statements I have put in an array $create
After including the file/code below I execute $create using:
foreach( $create AS $sql ){
$mysqli->query( $sql );
}
<?php //Tables.
$create = array(
"CREATE TABLE forums (
id INTEGER PRIMARY KEY,
name TEXT,
description TEXT,
position INTEGER,
canview INTEGER,
canpost INTEGER,
status TEXT
)",
"CREATE TABLE topics (
id INTEGER PRIMARY KEY,
forumid INTEGER,
postid INTEGER,
subject TEXT,
topictime INTEGER,
lastpid INTEGER,
lastptime INTEGER,
sticky INTEGER,
locked INTEGER,
status TEXT
)",
"CREATE TABLE posts (
id INTEGER PRIMARY KEY,
topicid INTEGER,
message TEXT,
posttime INTEGER,
userid INTEGER
)",
"CREATE TABLE users (
id INTEGER PRIMARY KEY,
uname TEXT,
pword TEXT,
email TEXT,
joined INTEGER,
regcode TEXT,
level INTEGER,
status TEXT
)",
"CREATE TABLE configs (
id INTEGER PRIMARY KEY,
label TEXT,
value TEXT
)"
);
?>