Sunday, January 04, 2009

Another day, another RDBMS

I had been thinking about transferring one of our computerised exams to a database system (RDBMS) other than the Borland Database Engine (BDE) and so tried using Firebird. Whilst this system works (of course), it seems too much like overkill for the project. There is also the small matter of rewriting the application, as the methods of accessing the data are somewhat different in FB as opposed to BDE (because the components which I used - dbExpress - support only unidirectional cursors with no buffering).

The other day I was playing around idly, trying to write an on-the-fly database component using the TClientDataSet, which would read its data from a disk file into memory, manipulate the data (even add more data) and then write the data to disk on program end. Whilst this is a nice demonstration of something, it doesn't really help my project, as this system seems to be limited to a single database table.

Then I started googling "single file databases" and came across this link to "EasyTable - [a] single file embedded database, a BDE replacement for Delphi and C++ Builder". What could be better? So I checked the site, downloaded the demos and a few utilities, ordered a trial key to unlock the library and started checking out the demos.

After a few false starts (and a slightly misleading email from the support team, which at least pointed me in the correct direction), I was able yesterday to convert my 'cinema/dvd library' program to work with EasyTable. The conversion went extremely fast, limited only by my ability to type and to click on components. This program has a few slightly advanced SQL queries, and EasyTable absorbed them without complain. As far as I could see, there was 99% compatability between BDE and ET on the component level (no unidirectional cursors), but ET does not seem to support a datamodule.

Well, not quite. I discovered that certain code would not work while I was in design mode but worked perfectly well when the executable file was run on its own, outside of Delphi. This doesn't make sense, so I've written to the support team again to hear what they have to say about this.

The reason why I am evaluating ET is that I want one of my applications, which uses several tables, to have those tables embedded in the executable file. ET will definitely support this, although it's not clear exactly how I am going to test this. I imagine that I will write a function which tests whether the database has been appended to the executable, and set a file path name variable on the basis of this result. The various queries will then use this path name. Had ET support for a data module, then I only need call this function in the dm and set the correct value in the database component to which all the queries are connected. It looks like I will have to set each query separately, which is a bore but not too bad.

Apparently the database also becomes closed and read-only when it is embedded. I can think of times when this is not appropriate behaviour, but in the case of the computerised exam which is to be distributed to clients, it is exactly what I need. EasyTable produces single user tables, so it will be of no use for the 'results' or 'administration' programs, which run from two different computers.

So: it looks like Firebird is out, until I find a real reason to use it. EasyTable is in, but only for special cases. With no reason to change, the BDE will stay the dominant RDBMS until it has to be changed to Firebird.

I still have to decide which one of three 'cinema/dvd' programs I will use, but that seems to be the least of my worries. As at the moment I have more data in the FB version, I think I'll stay with that.

No comments: