0

Working with MySQL I have a database with many tables and complex relationships.

Each table with data has a year and a month field for versioning purposes.

Is there a simple way to duplicate the entire set of data into the original tables given a year and a month, maintaining and relationships and incrementing the year and month fields as needed.

Currently I am doing this programatically, but the script can take a while to run as it needs to do a lot of validation on the rows I am copying.

I am open to any ideas on a better way to version this data also as I am not convinced this is the most efficient way.

Zack
  • 1
  • 1
  • you mean duplicate tables ? – RK. Aug 29 '14 at 04:40
  • If you've created a script to do it. Next time you run the script - ensure that you have the query analyser up and running. And see what comes out of it. Most likely there is a particular query (or two) that aren't optimised for best performance. – simo.3792 Aug 29 '14 at 04:46
  • @RK. I mean duplicate a row into the same table. Updated the question for clarity. – Zack Aug 29 '14 at 05:37
  • @simo.3792095 I'm using an ORM (Hibernate, eugh) to handle most of the script as the relationships can go deep and it's easier to let that handle the validation. It's definitely not optimised well at all! The problem I am having when trying to do this with a query is once I know a particular rows relationships, when I duplicate those relationships how can I reference the newly created IDs for that relationship in a query? – Zack Aug 29 '14 at 05:39

0 Answers0