I love DBMS and out of curiosity, I learned SQL in my college days. But now, in recent times, there is a lot of buzz in the market about NoSQL.
The first time I heard NoSQL, I thought, "What is "No SQL"?", and "Where can I go if SQL is my primary skill set?". After browsing through Google I learned that NOSQL is actually "Not Only SQL Database." (fun fact: it's still pronounced as it is spelled — "No SQL").
NoSQL stands for "Not Only SQL Database". Before we understand NoSQL we need to shed some light on RDBMS.
The most popular database model is Relational, also known as "RDBMS", or Relational Data Base Management Systems. A relational database management system (RDBMS) is a collection of programs and capabilities that allows IT teams and others to create, update, administer, and otherwise interact with a relational database. From the time it evolved, it is the most used model for the most successful databases.
RDBMS has its own rules to say a database is a Relational database. These rules have always been a highlight of RDBMS, and RDBMS will have a schema and a structure for data to be stored.
While the RDBMS model has many advantages, it also has a few disadvantages.
If you are familiar with SQL, how many times have you received the error; "Character can't be converted as Number." or was fooled by a Null as a value? Enough background on RDBMS. Let's move on to NoSQL.
NoSQL databases essentially evolved to overcome the pitfalls of regular RDBMS. There are different models of data storage and they are categorized as either Document Databases, Key value Databases, Column-oriented Databases, etc. I will emphasize the Document Database and mongoDB.
Document Databases store data as documents.
After completing a course on the basics of mongoDB, I noticed a few key points. The mongoDB will have DBs and collections in it, and a collection will have documents in it. If we compare that to our regular DBs, the collection is a table and the document is a record in the table.
The documents are stored as JSON type in mongoDB. For example:
Compass is the Graphical User Interface (GUI) used to access the mongoDB. The GUI has different sections and one of the most useful is the schema view. The schema view allows us to see the overall schema definition. There is also the documents view, where we can see the document. mongoDB has it own query language to access the database and can be used to CRUD (Create, Read, Update, and Delete).
Compass GUI:
If you do not have a value to insert for a particular column, do not mention that column at all while inserting it. Nothing great, ah. If we see in the DB after inserting the document, the column definitions themselves will not be there, meaning the structure does not need to have all of the columns.
In the example below, movieDetails is the collection where mpaaRating is the field in it. We want to query the documents where this field does not exist at all.
Here's how:
db.moviesDetails.find({mpaaRating: {$exists: false}})
This is how you query it from mongo. Shell is accessible from the command prompt after installing the mongoDB compass and the same can be queried through the GUI.
Here's how:
db.movieDetails.find({mpaaRating: null})
This will return the documents that not only have a null value in the field, but that do not have the field itself.
We typically have a data type associated with a column, but what if you provide a data type other than the actual defined one to store the data? The answer is yes, it is possible. It has flexibility and a particular field can have different data types.
It can also have nested documents and array types as fields in it.
MongoDB is useful for larger databases and the performance is spectacular. During one of my last courses, The Basics of mongoDB, they used some data lakes as a sample DB, and this is excellent. To maintain the higher availably of the database they have multiple replicas of the same database on different clusters. These clusters are provided by monoDB for which they charge.
mongoDB is easy to scale and also among the most popular NoSQL databases currently available. It can be found in many large organizations including The Weather Channel, The City of Chicago, Bosch Software Innovations, Chico’s FAS, and so forth.
There is no specific schema structure to follow in mongoDB and no complex joins are required to retrieve data. Content management, Delivery, and Data hubs mongoDB can also be used in Big Data.