, , , , , , ,

What are?

SQL Databases: Commonly called Relational Databases (RDBMS).

NoSQL Databases: Commonly called Non-Relational Databases.

What does that means?

The basic principle of the relational model is that all information is represented by values in tables, which are pre-defined in a schema. Thus, the tables can relate to each other and this dependence is ensured by the referential integrity (primary key, foreign key).

The basic principle of non-relational model is  the flexible schema (schemaless), so there is no check of integrity and relationships.


– Divisions

  • SQL: table database, only.
  • NoSQL: documents, key-value pairs, graphs or columns.
    • Documents
    • Key-Value
      • It works exactly like a dictionary or a data map. Stores a key and its value.
      • Examples: Redis, Riak, MemcacheDB.
      • Redis is one of the fastest NoSQL and stores hashes, lists, strings and many other things.
      • Example of an insert: redis_01
      • Source: http://redis.io/commands/set
    • Graphs
      • They use structures such as graphs, with nodes and edges connecting each other through relationships.
      • Examples: Neo4j, OrientDB.
      • Neo4J is the most known and fastest graph database.
      • Example of how the data is structured:Neo4J
      • Source: http://neo4j.com/developer/
    • Columns
      • They serialize the data in columns rather than rows. So instead of being so, as the RDBMS:
        • Cassandra01
        • The columns are serialized together, then it would be like this:
        • Cassandra02
      • Examples: Cassandra, HBase.
        • Cassandra is a database that is similar to SQL syntax and is widely used, including by Facebook.
      • Example of an insert: Cassandra03
      • Source: http://wiki.apache.org/cassandra/GettingStarted

– Focus

  • SQL: ACID (Atomicity, Consistency, Isolation and Durability) and the 4 attributes are guaranteed.
  • NoSQL: CAP (Consistency, Availability and Partition Tolerance), but only 2 of these attributes can be guaranteed at the same time.

– Scalability

  • SQL: Vertical¹. This means that would be needed a powerful server to scale and then move all the load for it. You can scale across multiple servers but it is a costly and painful process.
  • NoSQL: Horizontal². This means that would require an additional server to scale, doesn’t necessarily super potent and distribute the load between these multiple servers. Horizontal scaling is when you have the ability to run multiple instances on servers simultaneously.


¹ – Vertical scaling means that scales by adding more power (CPU, RAM) in your existing machine. It basically means promoting an upgrade on the server.

² – Horizontal scaling means that scales by adding more machines in your resource pool. It is the ability to increase the ability to connect multiple instances so that they function as a single logical unit. Basically, it means increasing the number of servers.

Which use and when to use?

First, it’s important to know that not always the discussion is about: Either one or the other. It’s completely normal to find cases where, for a given part of an application, SQL is better, and for part of the same application NoSQL fits better. But you must have common sense and to know whether it is really the case.

  • SQL: Whenever there is relationship between entities. Remember that in most cases the relational model works.
  • NoSQL: The main advantages in use compared to SQL are: the fact that is schema-free, scalability and speed. So it is noteworthy that the NoSQL does not replace the relational model but complements it. Flexibility is the word to use NoSQL.

Appendix: NewSQL

  • NewSQL is an upgrade of RDBMS using the best of SQL and NoSQL. It kept the features of SQL databases, implementing the innovations of NoSQL.
    • Examples of NewSQL databases: VoltDB, MariaDB.

That’s it, folks. Already knew NoSQL and NewSQL? Do you use? Let me know in the comments.