Jump to content

Can i get an opinion on best way to set up the database


turkman

Recommended Posts

at the minute my intranet has a basic messaging feature but its just in a table id name subject message. this means all posts are shown even if they are about different topics. If i wanted to give the user a chance to create seperate threads and keep the thread replies seperate, whats the best way to set this up?

 

Does each thread get a seperate table? i.e if someone starts a thread "my new thread" would i need to create a table called it and then put all replies to this thread in that table or is there one way of doing it all in one huge table.

 

i.e

 

postid threadid name subject message

 

 

then i could fill it like

postid threadid name subject message
   1         1      joe    hello      hello all
   2         1      max   hello     hello joe 

 

Then thread id would determine which thread each reply belongs too.

 

Whats the standard way of doing this?

 

Thanks.

Yes you could do it like that but personally I would create a table called tblThread and a table called tblPost with the following definitions

 

tblThread

id, threadTitle,startedDate,updatedDate,userWhoStartedThread

tblPost

id, threadId, userID, Subject, Message, date

 

Does this make sense?

makes perfect sense.

 

So id just have a start page which shows threads.listed from tblthread using a simple query. Id use this to build the link with GET data in the like i.e showreplys.php?threadid=2

 

Then in show replies i would take the get data and use that to build my sql query

 

 

i.e select * from tbl post where threadid = $getdata sort by id DESC 

 

right, sorry if this is a silly question im a noob and trying to figure out how this would work, just so its clear in my head before i start.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.