views:

159

answers:

2

We have a set of applications that work with multiple database engines including Sql Server and Access. The schemas for each are maintained separately and are not stored in text form making source control difficult. We are interested in moving to a system where the schema is stored in some text-based format (such as XML or YAML) with descriptions of field data types, foreign key relationhsips, etc.

When all is said and done, we want to have a single text file in source control that can be used to generate a clean database that works with both SQL Server, Access at least (and preferably is capable of working with Oracle, DB2 and other engines).

I'm certain that there are tools or libraries out there that can get us at least part of the way there. For one, I've found Altova MapForce that looks like it may do the trick but I'm interested in hearing about any alternative tools or libraries or even entirely different solutions for those in the same predicament.

Note: The applications are written in C++ and ORM solutions are both not readily available in C++ and would take far too long to integrate into our aging products.

+1  A: 

If you don't use a object relational mapper that does this (and many other things for you) the easiest way might be to whip up a few structures to define your tables and attributes in some form of (static) code and write little generators to create actual databases from that description.

That makes it easy for source control, and if you're careful when designing those structures, you can easily re-use them for other DBs if need arises.

David Schmitt
+1  A: 

The consensus when I asked a similar (if rather more naive) question seem to be to use raw SQL, and to manage the RDMS dependencies with an additional layer. Good luck.

dmckee
This is an interesting solution but by having things like foreign key dependencies in a separate layer that is database specific there's a good chance that the key behaviour difference between the DBMS could make the application function differently with different database backends.
Karim
Yup. That probably doesn't matter for my simple needs, but I wasn't terribly satisfied on an abstract level.
dmckee