Amazing world about data

Developer, ThoughtWorker, Data Architect and Data Specialist

Schema less databases and its ramifications.

Entity design in schema-less databases

2 minutes read

In the No-SQL land schema-less is a power full feature that is advertised a lot, schema-less basically means you don’t have to worry about column names and table names in a traditional sense, if you want to change the column name you just start saving the data using the new column name Lets say you have a document database like mongoDB and you have JSON document as shown below.


You have some corresponding code to read the documents from the database and lets say you lots of data in the database in the order of millions of documents. If you want to change the name of some attributes or columns at this point and the new JSON would look like


You will have to either change every document in the database to match the new attribute names or you have to make sure you code can handle both types of attribute names like

first_name = doc["first_name"]
first_name = doc["FIRST_NAME"] unless !first_name.nil?
middle_name = doc["middle_name"]  
middle_name = doc["MIDDLE_NAME"] unless !middle_name.nil?
last_name = doc["last_name"]
last_name = doc["LAST_NAME"] unless !last_name.nil?

This attribute name change also affects the indexes created on mongoDB, since the attribute name change is not across all the documents, an Index created on


will not index documents where the attribute name is FIRST_NAME, so you have to create another index for this new attribute name


As you can see this gets really complicated if you do multiple refactorings, over a period of time. So when you hear schema less make sure you understand the ramifications of refactoring the attribute names at will and its effect on the code base and the database.

Recent posts


See more