I hate Databases

No… I don’t hate databases. But I know a lot of people who do hate databases. Me, I love them, in many shapes and forms. Relational Databases, Object Databases, Hierarchical Databases, Even XML Databases. They all have their uses, the problem lies in the fact that many developers try and make them do things they are not supposed to be doing.

An Object / Relational layer (such as Hibernate; JDO or JPA) takes away a huge amount of power (and performance) from a Relational Database. Why are you using an OR layer instead of an Object Database?

Why are you storing those huge HTML pages and XML documents in CLOB’s in a Relational Database, or a DOM structure in an Object Database when you can use an XML Database instead?

Now you shouldn’t be deploying a different database for every data-type you’re using, but you need to be intelligent deciding both what database to use. If most of your data is objects (quite likely if your coding in an OO language), you should probably be using an Object database. If you’re storing a lot of text and XML, an XML Database is probably well suited to your application.

Many times however, the reason people choose a Relational Database has nothing to do with how it arranges it’s data. It’s not for the power behind SQL. It’s simply for the fact that they’re a well known, well tried and tested technology. If this is the case, write your application and data model before you start developing your database schema. Let a database log analyzer tell you which queries need to be refactored, or prepared, or turned into stored procs.

The point here: don’t hate databases just because you don’t understand them. That would be like not driving a car because you don’t understand how petrol is refined from oil.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: