0
votes

I have a database that contains data from last 4-5 years. The database has grown quite large and the application that uses this database has been working really slowly. I am looking to archive some data from all the tables. This database has 16-17 tables that have relationships amongst them and I am looking for a way to perform the archive operation so that I can archive/remove data for couple of years. I tried reading about APPEND and DELETE queries but I am not sure how to apply them on multiple tables.

Another problem is this application was created by somebody else I don't have enough knowledge about the database and the way tables are structured. Any help/suggestions are much appreciated.

1
There's not really enough info here to answer this because, like you, we are new to this DB too but can't see it. You can "Archive" data but is this really what you want? Why is it slow is the bigger question. Are data traveling over a network? Are data being represented out of complicated queried which take a long time to run? How big is the DB? How big (records and columns) are the biggest tables? What do the joins looks like? You can see there is a lot more to this than "archiving" old data because you probably don't want to delete anything. - Brad
How about just making a copy of the database as the "archive" and then deleting the old data from the current data base? - Don George
Have you tried decompiling the database? - user2204315

1 Answers

0
votes

The first thing you need to do is gain an understanding of your dataset. if you truly "don't have enough knowledge about the database and the way tables are structured", you're setting yourself up for one huge failure.

The most important piece is to determine how the tables are inter-related. If the original designer was competent, he should have set up relationships within the database and enforced referrential integrity. You will need to look at those relationships (go to the Database Tools tab and choose Relationships), or determine what relationships should exist between your data.

Once you've determined how your data is related, you will need to set up new Archive tables to mirror all of the tables you wish to archive. The easiest way to do this is to right-click on the table, then right-click elsewhere in the pane and choose "Paste". You will get a box that looks like this:

enter image description here

Choose "Structure Only", since you just want to set the table up. I would give them the same name as the original tables, with "_Archive" tacked onto the end. This way, it will be easy to determine which tables you're working with.

Next up, determine which are your "parent" tables and which are your "children" tables. You do this by determining which fields contain relationships to each other, and how they're related. Any tables with a One-to-Many relationship can be considered "Parents" on the "One" side, and "Children" on the "Many" side.

After this, you will need to determine how you wish to archive. Usually, there is some date field within your table that you can use as a guide. Say, for instance, you have a field called "Order Date". You can choose to archive anything with an Order Date of anything before 1/1/2010. So, to do so, you will need to write an Append query. You will append everything to your new archive table where Order Date <= 12/31/2009. You do this first for the Children tables, and then to the Parent tables.

After this, you will write a Delete query. Essentially the same process as above, but you're deleting from your original tables since the data has already been written to your archive tables. You MUST delete from the children tables first. Then do the same for the parent tables.

You can now move all the archive tables into a new database, and zip it up to minimize space. Once that's complete, you can Repair & Compact your database and the size should be much smaller.

Always remember to make a copy first! If you make any mistakes, you can't undo them. Creating a copy allows you to go back and retry without losing any data.