For those of you who have studied or worked in the field of database programming, of course you are familiar with the concept of RDBMS-based databases such as MS Access, MS SQL Server, MySQL, MariaDB, PostgreSQL, and SQLite. The concept of the RDBMS is a table-based database, where each data is arranged in tabular relations , especially in the Primary Key (PK) and Foreign Key (FK) columns.
NoSQL is different from SQL, it does not require a schema and does not have table relations, so it is more flexible. NoSQL databases continue to increase in number of uses, especially in big data implementations and real-time web applications . Its popularity continued to rise at the beginning of this millennial century, triggered by the needs of Web 2.0-based companies and handled applications .
What is NoSQL?
SQL is an acronym for Structured Query Language , which is a database concept composed of schemas, tables, columns, and rows. The query or syntax for calling data in SQL databases makes use of the table relation media. Multiple sets of data from different tables can be called simultaneously.
If the user wants to display the desired data only, it can be done with a particular query language design. The tables in an SQL database are a set of solid and fixed tables. Therefore, a slight change in the structure of one table may result in the failure of a query that has been programmed in the View or Trigger section. Constraints faced in SQL databases lie in the complexity of maintaining and developing the scale of the data. By first understanding the concept of SQL will be able to help you in understanding what NoSQL is.
Understanding NoSQL (Non SQL) is a concept and a flexible database model. In general and specifically NoSQL does not follow the rules of a relational database (RDBMS). NoSQL does not use the SQL query language either. NoSQL is a different database model compared to SQL.
The term NoSQL was first published by Carlo Strozzi in 1998 to name the database he was developing at the time, ‘Strozzi NoSQL open-source relational database’. Strozzi said that the way NoSQL worked at that time was ‘very different’ from relational-databases as a whole, which is the reason why he called it ‘NoREL’ which refers to the term ‘No Relational’.
At the end of 2000, NoSQL development began again, with the aim of overcoming the limitations of SQL, especially in terms of scalability and the potential for multi-structured data collection.
In early 2009, Johan Oskarsson, one of the developers at Last.fm reintroduced the term NoSQL when he organized an event to discuss “ open source distributed, non relational databases ”.
NoSQL databases were developed as a hope to solve the classic problems of SQL databases. NoSQL databases are different from SQL databases in that there is only one type of data storage method. The NoSQL database structure is more dynamic and flexible with four (4) types of data storage models, which are as follows along with examples and brief definitions.
- Key-value (KV) store : ArangoDB, Apache Ignite, Oracle NoSQL Database, Couchbase, Dynamo, Redis, Riak.
KV storage uses an associative array, also known as a map or dictionary as the basis for its data model. In this model, data is presented as a collection of paired CVs. - Document-based : Apache CouchDB, ArangoDB, BaseX, Clusterpoint, Couchbase, Cosmos DB, IBM Domino, MarkLogic, MongoDB, OrientDB, Qizx, RethinkDB.
The concept of document-based data storage is an idea of the concept of a ‘document’. Where every database implementation of document-based is generally assumed that the documents are encapsulated and encoded into a standard encoding format. - Column-based : Accumulo, Cassandra, Scylla, HBase.
Also known as the wide-column model, it allows very fast data access by using row keys, column names, and cell timestamps. The flexibility of the schema of this type of database allows records in its columns (columns) not to be consistent. Users can add columns in a specific row without having to add them in each record. - Graph-based : AllegroGraph, ArangoDB, InfiniteGraph, Apache Giraph, MarkLogic, Neo4J, OrientDB, Virtuoso.
In theory, graph-based structures consist of vertices and edges (data and connections) which can be referred to as data relationships. Graphs behave similarly as humans think, data is arranged in specific relationships among data units that have their own characteristics. This type of database is useful for visualizing, analyzing, and helping you to find connections between different data.
For more details, it can be classified into ten (10) types of data storage models, namely as follows along with examples (based on Stephen Yen’s observations).
- First Key-Value Cache : Apache Ignite, Coherence, eXtreme Scale, Hazelcast, Infinispan, Memcached, Velocity.
- Second Key-Value Store : ArangoDB, Aerospike.
- Third Key-Value Store (Eventually-Consistent) : Oracle NoSQL Database, Dynamo, Riak, Voldemort.
- Key-Value Store (Ordered) : FoundationDB, InfinityDB, LMDB, MemcacheDB.
- Data-Structures Server : Redis.
- Tuple Store : Apache River, GigaSpaces.
- Object Database : Objectivity/DB, Perst, ZopeDB.
- Document Store : ArangoDB, BaseX, Clusterpoint, Couchbase, CouchDB, DocumentDB, IBM Domino, MarkLogic, MongoDB, Qizx, RethinkDB, Elasticsearch.
- Wide Column Store : Amazon DynamoDB, Bigtable, Cassandra, Scylla, HBase, Hypertable.
- Native Multi-model Database : ArangoDB, Cosmos DB, OrientDB, MarkLogic.
What are the functions of NoSQL? How is it different from SQL?
NoSQL database functions are the same as classic SQL database functions, but with their own advantages and disadvantages. Like SQL RDBMS in general, NoSQL is useful for processing data and storing it to be reused or accessed by both the Server and Client. The data is stored consistently so that both the Server and the Client see the same data.
NoSQL adheres to the BASE rules, which are Basically Available, Soft state, and Eventual consistency . The data in it can change even if there is no input, it’s like an RDBMS with Triggers installed automatically. Because of this, NoSQL is more suitable and suitable for applications that require rapidly (fast) changes due to its more dynamic and flexible nature.
Advantages of NoSQL databases over SQL databases
In some cases NoSQL is considered to work better than relational-based SQL, including the following.
- When you need to store large amounts of data with inconsistent schemas.
The data schema in NoSQL is not fixed as in SQL, changes to the structure and schema that can change at any time can be handled easily without having to change the consistency of the data in the database itself. - When you need cloud-based computing and data storage .
Most NoSQL databases are built and designed to work in different data-centers and run as distributed systems. In this case you as a NoSQL user will benefit, because you can take advantage of access to various cloud-based computing infrastructures. - When you are a web-developer or app-developer and you need a fast ( rapidly ) update . With NoSQL you don’t need to prepare data as if you use RDBMS (SQL), you can even migrate structured data from one application version to the next updated version, whenever the application design is updated. The dynamic nature of NoSQL can evolve as the application changes.
Disadvantages of NoSQL databases compared to SQL databases
In the RDBMS database concept, there are ACID rules , namely four (4) data transaction rules. ACID is an acronym for Atomic, Consistent, Isolated, and Durable .
- Atomic means that each record or row is unique data, it cannot be replaced by other data.
- Consistent , each row of data is consistent data, meaning that the data will remain consistent after being executed with a certain operation. Server and client will see the same data.
- Isolated means that every change in one record is an independent transaction, not related to other record transactions.
- Durable , meaning that after the transaction is complete, the effects of changing the record are stored solidly and permanently.
NoSQL Database Types
In general, NoSQL databases are divided into four types, namely:
1. Key-value
This type of database stores the database in key/value pairs in the form of a simple hash table . So, it is suitable for use by those of you who want to store a lot of data without using complicated queries when processing it.
In key-value, each key is unique, while the value can be JSON, BLOB (Binary Large Objects), string, and so on.
Some popular key-value databases are Redis , DynamoDB , and Riak .
2. Column-based
Column-based (also known as wide-column) is a type of NoSQL database that stores data in columnar form. So, column-based is perfect for querying SUM, COUNT, AVG, MIN, and the like.
The main advantage of column-based NoSQL is its column flexibility. Each column is independent of any other column. So, you are free to change any column without affecting the others.
Some popular column-based databases are HBase , Cassandra , and Hypertable .
3. Document-oriented
This type of database uses data that contains a key and value pair that is stored in a document in JSON or XML format. Value here can be in the form of strings, numbers, booleans, arrays, to objects.
For those of you who are familiar with JSON, you will certainly see the similarity of the structure used by these types of NoSQL. The structure is different from a SQL-style relational table which has rows and columns.
With this approach, you don’t need to know the columns beforehand like in SQL. Very flexible, right? Not surprisingly, this type of document-oriented database is mostly used for CMS, blogging platforms, real-time analytics, and e-commerce applications.
Some popular document-oriented databases are Amazon SimpleDB , CouchDB , and MongoDB .
4. Graph-based
Graph-based is a type of NoSQL database that focuses on storing relationships between entities. These entities are stored in the form of nodes, while the relationships between entities are referred to as edges.
Graph-based is very suitable to use if you want to find patterns that are interconnected in the data. Therefore, this type of database is generally used for social media, fraud detection, and spatial data.
Some popular graph-based databases are Neo4J , JanusGraph , and InfiniteGraph .
Difference between SQL and NoSQL
Here are the differences between SQL and NoSQL that you can consider before using them:
Difference | SQL | NoSQL |
Type | RDBMS or Relational Databases | Non-relational database or distributed database |
Function | To process data in Online Analytical Processing (OLAP) | To process data related to increasingly complex modern applications and websites |
Query language | Structured query language (SQL) | Does not require a query language that is too complex |
Database structure | Table shaped | Can be in the form of key-value, column, document, and graph |
Schema | Need to be determined first | Dynamic schema for unstructured data |
Scalability type | Vertical scale or scale up by buying new hardware. | Horizontal scale or scale out by adding servers. |
Example database | MySQL, Postgres, MS-SQL | Redis, Neo4j, MongoDB |
This is the reason why RDBMS is called a fixed database. NoSQL does not meet the ACID rule, it can be Consistent but it cannot be Atomic, Isolated, and Durable. NoSQL is not suitable for applications that require fixed data such as employee biodata records, population censuses, medical records, fingerprint records, and many other examples. Hopefully this article about understanding NoSQL is useful and easy to understand!