A government organization provides data in a series of files which can be re-engineered and imported into a database. The files are updated monthly. I have been able to reengineer the database in MySQL and import the data. I've also created additional tables on the database and added my own data. My issue is I'm unsure as to how to handle updates to the database.
How do I import the data every month and sync it with the database from the previous month, which would include the tables that I added?
Best Answer
If the imported data has artificial ids (such as from
AUTO_INCREMENT
), and your tables are referencing that data via those ids, and each "update" changes those ids, then you need to rethink.If the imported data has "natural" keys that do not change with each "update", then you are safe.
If the "update" is really a complete set of data, then to reload, do this for each table
Keep the
old
tables around until next month -- you may have to revert, or you may want to compareold
toreal
to see, or react to, what changed. SeeLEFT JOIN
to discover what is added/removed. Use a plainJOIN
to see what values have changed.