What is NoSQL?
Before you can begin to use MongoDB properly, it's important to understand its architectural underpinnings. Key to this understanding is what is often referred to as NoSQL. As the rubric implies, a NoSQL database does not use SQL language. More importantly, this means that a NoSQL database is free from the legacy, two-dimensional restrictions that handcuff the traditional RDBMS.
There is no formal definition of NoSQL, but there are certain common characteristics. First of all, a NoSQL database does not adhere to the relational model. This is evident in that MongoDB has no fixed schema, no tables, columns, or rows. A second consideration is that NoSQL databases are driven by the needs of big data. Accordingly, NoSQL databases tend to be scalable as well as distributed. This aspect is visible in the MongoDB feature called sharding, where shards of the database are distributed to a cluster of servers.
Finally, lacking tables, rows, and columns, NoSQL databases use other modeling paradigms. These include:
- Graph (https://en.wikipedia.org/wiki/Graph_database): A database technology designed in an almost visual manner, where basic entities that need to be stored are represented as nodes. These are connected by edges, which can be thought of as lines connecting the various nodes. Finally, there are properties, which are like metadata on the nodes. An example of this type is Neo4j (https://neo4j.com/).
- Key/Value (https://en.wikipedia.org/wiki/Key-value_database): Where data is stored as keys and values. This is analogous to a multidimensional array where values can be quickly and easily obtained by simply referencing the key. Some graph-style databases make use of this technology internally. An example of this type is Redis (https://redis.io/).
- Wide column (https://en.wikipedia.org/wiki/Column_(data_store)): This technology is also analogous to an array with key/value pairs. The difference is that a third element is added; a timestamp. Also, different columns, or even partial columns, can be stored on different servers, lending it to cloud-based computing. An example of this type is Cassandra (http://cassandra.apache.org/).
- Document (https://en.wikipedia.org/wiki/Document-oriented_database): The document-style database uses what amounts to an object as its smallest logical unit. Multiple documents are stored in a collection. Each document can have the same fields, which facilitates querying. On the other hand, as there is no fixed schema, each document could have a different number and type of fields, which contributes to flexibility. An example of this type is MongoDB.