[NoSql] 4 Types of NoSQL Database

1. Key-Value Stores

Popular db: Redis, Dynamo

2. Document Databases

2.1) Features

  • Data are stored as 'object' in some standard encoding, such as json or xml.
  • Sub-class of key-value store.
  • No schema (because this is NoSql)
  • Key-Document Relationship
    • The key is used to retrieve the document from the database.
  • Query by content/metadata
    • Beyond key-to-document lookup, database offers an API or query language that enables users to retrieve documents based on content/metadata.
    • For example, you may want a query that retrieves all documents with a certain field set to a certain value.
    • This is what uniquely differs from key-value stores.

2.2) Popular Databases

MongoDB, CouchDB

3. Column Databases

3.1) Features

  • Instead of storing data in rows, these databases store data by column.

3.2) When to use?

  • Highly dependent on use case: During retrieval, does requested data have attributes that we don't always need?
  • Good for Business Analytics or high availability architecture.
  • Flexible capacity and near-infinite scalability

3.2.1) Good Example

I only need the login_count of all my users.

This is a good use case because we only need to access the 'login_count' column (rmb that the data is stored by column). If we used row-db, we need to access n rows and get login_count for each row.

3.2.2) Bad Example

I need all the attributes of a particular user.

This is bad because to do this, we need to loop every column (because data is stored by column). If we used row-db, it would be better because we just need to find the row. 

3.3) Popular Databases:

Cassandra, HBase, BigTable, HyperTable

4. Graph Databases

4.1) Features

  • Uses the idea of 'connections'.
  • Composed of two elements: node and relationship.
  • Each node represents an entity (eg. person, place, thing) and each relationship represents how two nodes are associated.
    • Eg. Two nodes, cake and dessert, have a relationships of 'is a type of'

4.2) Why this works?

  • In traditional databases, relationship queries comes to a grinding halt as number and depth of relationship increases. In graph db, this stays constant even as your data grows.
  • Relationships take first priority. They are not temporarily calculated, but are persisted.
  • Flexible - No need schema

4.3) Popular Database

Neo4J



Resources:


Comments

Popular posts from this blog

[Redis] Redis Cluster vs Redis Sentinel

[Unit Testing] Test Doubles (Stubs, Mocks....etc)

[Node.js] Pending HTTP requests lead to unresponsive nodeJS