If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Archiving Data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-11-08, 09:00
foreman_bob foreman_bob is offline
Registered User
 
Join Date: Mar 2008
Posts: 2
Archiving Data

Hello!
My goal is to create 'shadow' tables for all of the tables in my database. For instance:

'Customers' table would have a shadow of 'Customers_Arc'.
'Orders' table would have a shadow of 'Orders_Arc'.

Whenever a row gets inserted or updated, a new row gets added to the corresponding _Arc table with the the row as it is when inserted or updated. When a row is deleted, a row is inserted to the _Arc table with a 'Deleted' column (bit flag) turned on.

Ideally I would use a script to generate the _Arc table(s) and triggers. Does anyone know if something like this is out there and available? Possibly a MyGeneration template?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 03-15-08, 15:34
websitehacks websitehacks is offline
Registered User
 
Join Date: Mar 2008
Posts: 11
I don't know of anything like this, but if all that you're trying to do is have copies of every table, this is very easy. The best thing to do is just do daily backups. I think this may be less strain on your server. Otherwise, if you insist on having instant backups, just modify your scripts. Depending on how complex your scripts are, it seems that all you would have to do is copy your queries and change the table names. Does that make sense?
__________________
Website Hacks
Programming/computer help
Reply With Quote
  #3 (permalink)  
Old 03-16-08, 07:18
koriba koriba is offline
Registered User
 
Join Date: Mar 2008
Location: Windhoek Namibia
Posts: 13
Hi,
Your problem is a pretty std one. Just taking backups of the tables is not what you want (I think).

I have often been approached to solve this problem - Mostly for audit firms that would like to track the changes to tables at a detailed level. (Even access of data)

Although there are many approaches to this the best - and most sustainable way is to employ a SINGLE "go-through" script for access / write to etc. to your databases.

At the same time simply insert the SQL statement being executes into a table. The results are that you save each and every SQL statement in a separate table (s_log).. after execution in the target table. This is usually done through a data logic layer (attached in PHP code).

This is very useful since it is a superb backup. If the statements (excluding the SELECT ones) are re-executed in a sequential way a table may be re-created from scratch. - This table (s_log) is backed up regularly on all my systems and in some even trickled to another database for posterity and detailed reporting.

The script for the table structure and sample code in PHP is in the attachment .. the results also..
Although the code is in PHP (oo code) the comments are simple to read and should be self-explanatory..

If you think this may solve your problem let me know.. I will expose a detailed doc on it on my site. GOOD LUCK!

Wayne
Attached Files
File Type: txt xxxx.txt (6.9 KB, 52 views)
__________________
Wayne Philip - openaxon.com
Reply With Quote
  #4 (permalink)  
Old 03-16-08, 09:19
foreman_bob foreman_bob is offline
Registered User
 
Join Date: Mar 2008
Posts: 2
Thanks for the replies.
I wound up creating an app for myself that will meet my need. Feel free to reply with suggestions on how to improve it!

You can read about and download it here: http://foremanbob.*************/2008/...-in-mysql.html.

Last edited by foreman_bob; 03-16-08 at 10:06.
Reply With Quote
  #5 (permalink)  
Old 03-16-08, 10:21
koriba koriba is offline
Registered User
 
Join Date: Mar 2008
Location: Windhoek Namibia
Posts: 13
Good .. Go well
__________________
Wayne Philip - openaxon.com
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On