Look ma, no schema

by abhirama

Due to the plethora of NoSQL database choices available, schema less is a tantalising option these days . While starting, NoSQL databases sound attractive but reality sets in when the maintenance problems start creeping up later.

nosqlpng

If you are doing anything with data, you need to know the schema of that data. What this boils down to is whether this schema is explicit or implicit. In relational databases, schema is explicit and well documented whereas in NoSQL databases, schema is implicit i.e it is maintained in code. All the goodies that you get with relational databases like integrity checks, constraints etc should be taken care of in code.

Products go through multitude of changes, features get added and axed and in order to accommodate this, schema has to change accordingly. In relational databases, carrying out schema changes on tables with large amounts of data is a daunting problem which requires considerable planning and effort. This problem is not present in NoSQL databases, but again, you end up managing this in code. In order to handle multiple versions of the schema, code gets littered with if else statements. This gets even more messy as this is spread across wherever data is being handled. In relational databases, you handle schema changes once and for all, in NoSQL databases, you continue to do it in code long after the change.

Multiple people work on code at different points of time, people join and leave teams but code lives on. This is when the maintenance problem starts raising it’s ugly head. A big reason a lot of startups opt for NoSQL databases is due to the constant flux in these organisations. Requirements change frequently due to which a stable schema design becomes next to impossible. In this landscape, NoSQL databases look like God’s gift to mankind. If your company does not fall in this bucket and you find yourself tempted to use a NoSQL database, take a good hard look at the problem and ensure that it is worthy of a NoSQL database. There are problems which are better solved with a NoSQL database but these are far and few.

Advertisements