Jump to content

DB Housekeeping, Best Practise


lunac

Recommended Posts

Ok, I'm trying to plan ahead and I can use a little advise. I'm writing an online class registration system. I have a table "student2class" which is to match students with the classes they've enrolled in, much like you might do post to categories in a blog. Anyway... Each quarter there is a new set of classes and student registering. My worry is that after awhile, this table will get large and difficult to manage. I don't really need to keep record of students2class in past sessions ( that information is tracked within the student profile), so classes can be removed once a session is over.

So... what I need advise on is the best way to go about cleaning out the table. Is it better to just delete all past classes -- the id auto increments -- will that be an issue? Or is it better to create a new students2class of each session -- student2classfall06 -- then drop that table when the session is over? Or is there an even better way I haven't thought of?
Link to comment
Share on other sites

[code]
TRUNCATE TABLE `student2class`
[/code]

If you are sure you don't need the old information just run that query at the end of each session and it'l clear all of the DB contents, the rows, leaving the fields the same, and restart the auto increment ID field for you.
Link to comment
Share on other sites

  • 2 months later...
Well, first, unless it gets really, really large, I wouldn't worry about it.  Second, I wouldn't truncate, because then you'll have uid issues if any other tables link to this one.  Third, you can always archive portions of this table, and then DELETE the non-active ones.  Fourth, if you want to get really fancy, make a MERGE table of most recent two or three "tables".
Link to comment
Share on other sites

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.