Jump to content

Keeping data organized by updates, aka bump


Recommended Posts

I'm working on scripts for an imageboard/forum and just realized I don't know how to reorganize the table based on the most recent update. I have a thread table and a reply table and I want to write the script so when a reply is made the coresponding thread gets moved to the bottom of the thread table. And it also doesn't change the Id which is the primary key and autoincremented. I was thinking about making another table that would keep track of the order and just reference the thread list and constantly delete/insert columns to make them in order. That seems inefficient to me, especially if you look at popular forums and imageboards that have replies and new threads flying in by the hundreds per minute.

If anyone knows anything that could help I'd really appreciate it. Thanks in advance.

How do I change the order though? Would I change the order in the tables or write a script to figure out the order to display everything? I think that'd be slower because I'd have to query the reply table, figure out the x most recent threads that were replied to, then query the thread table for those threads, and repeat for each page of posts. I'm sure I'm just thinking about it the wrong way. I would probably need to join the two or something in one query.

I would probably need to join the two or something in one query.

 

Yup.

 

Moving data around to keep it ordered is not so good an idea. Instead try to write a smart query. As far as I know, every other forum software does it this way ;)

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.