Relational Databases and Document Databases

nand
2 min readApr 25, 2018

--

In 90’s and early 20’s, MySql was synonym of database. There were other db’s as well like oracle but mysql was industry standard.

These were very reliable databases, they had strict policies, were ACID compliant and were highly consistent. But these ACID compliance comes with a cost. They reduce performance.

Performance was not a concern back in the days but with such large amount of data being generated now, need for less strict and more performant databases arise.

What we needed was more flexible database with high write throughput.

That’s where Document based DBs comes in. They are popularly known as NoSql.

MongoDB, Cassandra, DynamoDB are some of the popular Document based DBs.

Use cases of Relational DBs

  • When your data is transactional like banking, payments systems. For transactions, data should return to previous state in case any of the operations in transactions fails.
  • When reliability is more important than performance. Like for log data, loss of few packets is not big a deal, but for banking transaction, reliability is of utmost importance.
  • When we need join queries. RDBMS join queries are highly performant.
  • When you need to maintain relationship between different entities, especially like many-to-many relationships.
  • For highly connected data, documents based model doesn’t work well.
  • Querying connected object is much better. Document has nested object, so its hard to search inside nested data.
  • Its easy to update data as you update at single place and since related tables have foreign_key reference, those will be updated too. Very difficult in document based.
  • When you want uniform, less ambiguous data. We can have proper check and balance to what kind of data to store, hence data is very uniform. Like price column will have numerical data only.
  • Here you store ID (foreign key) instead of actual text, this way data is not duplicated at various places. You just have same ID at all the places. ID never changes, only the data associated with ID changes.

Use cases of Document based DB

  • When you want schema less storage meaning where you are not bounded by schema of tables. When schema is ever changing.
  • When you want flat and nested structure that way you won’t have to join multiple tables to query all the data of that entity. This is also called localisation.
  • When you want high write performance at cost of some loss like log data.
  • When you want json storage like mongoDB has much better json support.
  • Cassandra, dynamoDB has better partitioning support, meaning you can distribute data on multiple nodes. READ

There’s further classification between document based DB’s like

  • Redis: Used as a key-value db and as a Cache
  • MongoDB: Storage for data from various sources like sensors. Most popular schema less DB.
  • Cassandra: For Time-series and distributed data storage.
  • Hbase: Mostly used with Hadoop
  • Neo4j: Mostly graph storage. When your data is highly connected liked friend circle, movies db

There are many other Nosql db’s in the market, but above ones are the popular ones.

--

--

No responses yet