What is NoSQL? Can I eat it ;)

Tram Ho

(Source: Making Sense of NoSQL A guide for managers and the rest of us (Books))

 

Top 10 DBMS according to the latest statistics of DB-ENGINES

RDBMS (Relational Database Management System) is too familiar to us. What about NoSQL? What is NoSQL? Why is NoSQL growing more and more widely applied instead of RDBMS as before? If you’re as curious as me, let’s find out ?

1. Why NoSQL

Before NoSQL, DBMS programmers said that RDBMS is “one size fits all”, temporarily understood as a standard that can be suitable for everything. But as the actual issues “technologyized” more and more, this assertion is no longer accurate. That is why NoSQL was born. In other words, NoSQL is an alternative solution, to solve the problems that RDBMS is having.

NoSQL database is a database built for data model and has flexible schema to meet the requirements given in building modern applications. NoSQL database is widely recognized for its ease of development, functionality and performance at large scale. These databases use diverse data models such as document, graph, key-value, …

2. Problems of RDBMS

First, it must be confirmed that RDBMS has many advantages:

  • Calculates the ACID (Atomicity, Consistency, Isolation, Durability) of a guaranteed transaction.
  • Standard 3 ensures consistency and consistency of data).
  • There are many drivers for every language: Java, C #, PHP …

RDBMS is also a traditional management system, so it is quite popular and widely known by most programmers.

However, it still has disadvantages such as:

  • If true, performance may be slow if you have to join multiple tables to retrieve data. That is why we use “benchmark reduction” to increase performance for RDBMS.
  • Difficult to expand or change the table structure: Adding / deleting tables or adding / deleting a field … can lead to countless source code changes.
  • Cannot work with unstructured data.
  • RDBMS is designed to run on a server. When you want to expand, it is difficult to run on many machines (clustering).

For example : When you need to save the profile – User profile . If it was before, then maybe just save 1 email, or 1 phone number. But as life develops, a user may have several phone numbers and several emails, the query becomes more complex.

Suppose a person has 3 phone numbers, 5 emails and 2 addresses, so a SQL Query might require 3 x 5 x 2 = 30 records.

And the more “the database” grows, the more complex the query becomes and can reduce the performance of the system.

Not to mention that in addition to phone numbers and emails, we also need to save users’ social accounts such as facebook, twitter, github, … At that time, we need to add fields to the table. With RDBMS, in each of these cases, you might affect many of the current queries of the system.

3. Benefits of NoSQL

As I mentioned above, the NoQuery scalable database and NoSQL data model solve a number of problems that the relational model does not solve. Specifically some of the benefits of NoSQL are:

  • Flexible schema : NoSQL can do with unstructured data. As a result, NoSQL database is the ideal choice for data that is not organized into structured or incomplete structures.
  • Elasticity: Changing the data structure (Add / delete fields or tables) is easy.
  • High performance : NoSQL databases are optimized according to the data model (for example, text, key-values ​​and graphs) which makes it easier to query than the relational RDBMS database.
  • Scalable : Because of the lack of ACID of transactions and data consistency, NoSQL DB can be extended and run on many computers easily.

4. Types of NoSQL databases

4.1. Document databases

Characteristics:

  • The objects are stored in the database as a document.
  • Format: BSON / JSON / XML.
  • Documents are identified by their IDs.
  • Allows indexing by attribute.

Advantages:

  • Can add / edit attributes, changing objects (equivalent to changing fields and tables in RDBMS) very quickly and simply
  • Can execute complex queries with high performance

Disadvantages: Each database has its own type of query.

Application: prototype, big data, e-commerce, CMS, …

Typical DBMS: MongoDB, RavenDB, CouchDB, TerraStone, OrientDB

4.2. Graph stores

Characteristics:

  • The data is stored in the database as nodes, connected together to form graph structure.
  • Each node will have 1 label and some properties – similar to 1 row in RDBMS.
  • Nodes are connected by relationships.
  • Queries are graphical browsing algorithms.

Advantages:

  • Quick and easy search queries
  • Neo4j is a free database, it has a huge sharing community.

Disadvantages: Must browse internal graph, when querying. Not easy to disperse.

Applications: Social networks, noron networks

Typical DBMS: Neo4j, InfiniteGraph, OrientDB, HYPERGRAPHDB

4.3. Key-value stores

Characteristics:

  • Store in database as key-value pairs
  • Use the key to search for value.
  • The value can store any value.

Advantages:

  • Simple key-value structure.
  • Quick query
  • Easy to expand

Cons: Cannot reverse query from value to key.

Applications: Storing caches, sessions, profiles, … for applications.

DBMS: Riak, Redis, MemCache, Project Voldemort, CouchBase

4.4. Column-family stores

Characteristics:

  • Data is stored in database as columns, instead of rows as in RDBMS.
  • Columns are grouped into “column-families”.
  • Column-families are grouped into “super-Columns”.
  • Can query all columns by column-families or super-columns
  • Similar data is grouped to improve query performance.

Advantages: Easy to expand

Application: some CMS projects and in e-commerce.

DBMS: Cassandra (Developed by Facebook), HyperTable, Apache HBase

5. Future trends?

NoSQL ignores the data integrity and ACID transaction of RDBMS in exchange for fast performance and scalability. Therefore, NoSQL is applied in Big Data projects, Real-time projects, … with huge amount of data or no specific structure. At the same time, NoSQL will not be able to completely replace RDBMS. However, instead of “one size fits all” as before, now projects will use not only RDBMS or NoSQL but probably both. Therefore, improving SQL knowledge as well as learning more about NoSQL is extremely necessary for every programmer.

This is a topic, say like, huh, it seems a bit lost in the topics I usually learn (Actually I also wrote about this topic in an article a long time ago). But in fact, I have not practiced much with NoSQL projects and I only understand that NoSQL database is a “non-relational” database so I want to learn more. The article only includes theory but I hope it is still useful to you. I will try to have the article with specific examples and more useful.

Thank you for reading. See you in the next posts.

References:

NoSQL Databases Explained

Database Trend

WHAT IS NOSQL OR HO – OVERVIEW OF NOSQL: Part 1 and 2

What is NoSQL?

Contact me if you have any questions or suggest topics for me here: HaiHaChan

Share the news now

Source : Viblo