The Ultimate Business Machine - Archives
List of Categories : Database * Technology * Commentary * Singapore * Travel *
Mon 16 Oct 2006
PostgreSQL and Luca
Category : Technology/Luca_PostgreSQL.txt
I've built a database connector framework, over the last few days, to allow Luca to store its data into a PostgreSQL database.
I've been able to populate a Postgres database with data needed by Luca, and that was rather satisfying - that our framework's structure works across four database types now.
But I've hit a curious snag.
I've named my database columns using mixed case because "currencyCode" is much easier to read than "currencycode". But PostgreSQL "folds" all column and table names to lower case, by default. So my column is named "currencycode" in Postgres.
When the data is read back into Luca, they're packed into dictionaries so that it's easier to access each field value using Objective-Cs "valueForKey" construct.
But C, on which Objective-C is based, is of course case-sensitive and so 'valueForKey:@"currencyCode"' which I use all over the code does not work now that the key, that is returned from Postgres, is called "currencycode".
There are various ways of solving this, with a variety of trade-offs. So I'm mulling it over.
But, if you're management, how do you assess this situation? Should you allocate resources to explore the options and produce a solution? First question, "why bother?".
Well, PostgreSQL is free, and there are no contraints on its use, whether for commercial or open source development. It's easy to install, or at least the Mac OS X installation went like a breeze (use Marc Liyanage's installer). And PostgreSQL has been known to break new grounds that later became standard features on other databases. So this is a great tool to have in your toolset.
There are some questions whether MySQL's licensing will allow its C API to be embedded inside a commercial application, with no restrictions. Sometimes, I read, yes; sometimes I'm not too sure.
But there are no such ambiguities with SQLite and, I think, also with PostgreSQL. And so, with SQLite forming the core of a light-weight embedded database that is shrinkwrapped into Luca, and PostgreSQL for people who need multi-user, concurrent, client-server access with transaction locking, that should cover all the bases.