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
https://forums.phpfreaks.com/topic/26899-db-housekeeping-best-practise/
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.
  • 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".

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.