View Full Version : design pattern for supporting multiple DB's?

3rd June 2010, 14:49
Up to this point my whole system has been Windows based using technologies other then Qt. I have started working on a Qt module which will ultimately go cross platform. One of the other things it is going to do is support two databases, both SQLite and Firebird. I do plan to keep as much of the DB simiar as possible, but there are a few syntax issues and feature differences. Can anyone suggest a good design pattern/approach to supporting both DB's?

FYI: In time I might support additional DB's, ideally I would like to implement things in away that does not lock me into a fixed number of DB's.


4th June 2010, 14:56
Why would you like to use multiple dbs? Additional it is useful to know for what job you use the dbs.

4th June 2010, 15:12
Why use multiple databases? Very simple, I have different levels of my software. The basic version only needs basic features, all of which are provided by SQLite. The more advanced versions need more advanced features provided by client/server style DB's.

This is the same theory behind what both Microsoft and Oracle have done: They have one super light DB designed to be embedded and is normally free, to compete with folks like SQLite. But then using the exact same code base, it can scale to an enterprise wide system with the big expensive DB's.

I need to be cross platform, so both Microsoft is not viable options, the enterprise option only needs like 10~20 clients so something like Oracle simply isn't cost effective. On the other hand, SQLite and Firebird are perfect solutions. Now I just need to figure out how best to implement the Qt code to handle both versions of the DB.

I started to look at the Bridge pattern, but got pulled away from that before I could really get into it. At the offset, it looks like overkill. Not quite sure at this point.


4th June 2010, 15:33
I would propose you to use the "Data Access Object" Pattern, it is original designed for java. But it seems to me, that you have the ability to adept it to c++.