I am going to make this a more general question. The original question with my scenario's details is below, if interested.
If you are replicating a database and need to convert data types on some fields in order to work with them, would you modify the data types for the fields in your local table and cast the data upon importing, or would you import the data as it is and then cast the data upon reading and working with the data?
Why would you choose one option over the other?
Question as I originally asked: I am working with Quickbooks Online data, and need to replicate my company's database locally because Intuit's server-side restrictions will not allow me to use ordering or where clauses in my select statements the way I need them for my reports.
So I am working on creating a replication on my personal MySQL server simply to have a local cache of the data that I can freely create reports with.
I have an ODBC driver that connects directly to my company file on Intuit's system, and have used MS Access to read the linked tables and export them to my MySQL server.
The numeric keys for each table are stored as varchar(255) and the foreign keys are stored as mediumtext. I thought maybe the ODBC driver is just lazy, but one look at the API documentation shows that Id fields are definitely stored as strings.
Naturally, in order to work with this data, I need to convert the keys and foreign keys to matching data types before doing anything else.
I am wondering if I should alter the schema of the local MySQL tables and perform the cast upon import, or if I should maintain data integrity and import the data as received and then cast the data types using views, or perhaps even in crystal reports' select statements.
If I alter the table and for some reason a future import contains a record that does not match the data type, the import will fail.
But if I retain the table structure, my ability to use indexes and ordering is diminished.
What is the proper way to handle this? Is there another option that I am not aware of?
Thanks