Free2Code
The majority of forums are now only available as archives, which means posting/editing is disabled.

The Anything and Everything forum is still open.
 
Time: 2013-05-21, 11:33pm
creating a database
Subject: creating a database  ·  Posted: 2005-06-02, 03:55pm
Rank: ? (8)
Member #: 24204
Where's some good tutorials, or someone, who can help me build a database for my forum software I'm wanting to code.

 
  Reply to this ·  Post link ·  Top
Subject: Re: creating a database  ·  Posted: 2005-06-10, 01:31am
Rank: Unregistered
ask away

 
  Reply to this ·  Post link ·  Top
Subject: Re: creating a database  ·  Posted: 2005-06-10, 02:09am
Rank: ? (4827)
Member #: 3416
here's the tables i use for my forums:
Code:
  1. create table oigroups (
  2.   id tinyint unsigned auto_increment primary key,
  3.   sort tinyint unsigned,
  4.   title varchar(255)
  5. );
  6. create table oiforums (
  7.   id tinyint unsigned auto_increment primary key,
  8.   gid tinyint unsigned,
  9.   sort tinyint unsigned,
  10.   title varchar(255),
  11.   description varchar(255),
  12.   threads smallint unsigned default 0,
  13.   posts int unsigned default 0,
  14.   lastpost smallint unsigned
  15. );
  16. create table oithreads (
  17.   id smallint unsigned auto_increment primary key,
  18.   fid tinyint unsigned,
  19.   title varchar(255),
  20.   instant int,
  21.   uid smallint unsigned, index (uid),
  22.   posts smallint unsigned,
  23.   lastpost smallint unsigned
  24. );
  25. create table oiposts (
  26.   id smallint unsigned auto_increment primary key,
  27.   tid smallint unsigned,
  28.   subject varchar(255),
  29.   post text,
  30.   instant int,
  31.   uid smallint unsigned, index (uid)
  32. );

currently i have one group, with the title 'general discussions.' this is used for grouping the different forums together on the main page, and if my forums get enough posts that it makes sense to split off some new forums, i'll probably add more groups.

forums are assigned to a group by setting gid to the id of the group. threads and posts are counts that are updated whenever someone starts a new thread in that forum or posts a reply in that forum. these are displayed to show how active the forum is. lastpost holds the id of the most recent post in that forum, used to link to that post from the main listing and also get the timestamp of the last post so people know if they should look for new posts in that forum.

threads are assigned to forums using fid. instant is when the thread was started. uid is the id of the user who started the thread (or 0 if started by an anonymous user). posts and lastpost work the same as they do in the forums.

you can probably figure out what posts is all about from there

note that when a thread is started, i create an entry in threads and also an entry in posts containing the text the thread was started with.

my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top
Subject: Re: creating a database  ·  Posted: 2005-06-13, 06:08am
Rank: ? (171)
Member #: 11947
that one looks good, but depends on what type of databse (mysql, oracle, mssql..., at least for syntax)

just think about what you need and what you want to do, then break it into groups..

a form would have posts and users, at a minimum...

under posts you might have: folder, subfolder, ID(PK), date, subject, body, user, parentID.

folder and subfolder aren't necessary, but for grouping purposes might come in handy. parentID would be 0 if it is the start of a thread, otherwise the id of the parent (obviously , right)

under users you'll have: id(PK), group, name, accesslevel, avatarURI, signature, location, profile...

you get the picture....

 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

Penguino AVR

Want to learn about robotics or microcontrollers?
Check out the Penguino AVR from our friends at
Icy Labs