I am facing a problem with extracting data from a database. The problem is that I have more than one version of the database. Each version differs in the number of columns available and also the name (label) of columns may also change.
For example:
One version has column with the name contact, but with another version is contact_name (they represent the same information).
The question is how can I deal with such a situation where the column names can change from one database version to another. Also, if possible, reduce the need for changing my source code if more information (columns) has been added to the database.
I want to hear some suggestions before I start coding.
If you can’t change the databases have a look at implementing an abstraction layer between your code and your database:
You can then develop without worrying about the underlying structure, and contain all of information about what columns to use in what database within this layer.
In practice, what you’d use would depend on what language you’re using, what database you’re using and how the application is designed.