In today’s world, data is everywhere, multiplying exponentially every moment and being harnessed and manipulated to power activity, innovation and growth all around us. In order to manage all this data, we use software called Database Management Systems, or DBMS, which store, retrieve, define and maintain data in a database.

Relational Databases

MySQL is a relational database management system, or RDBMS. In relational databases, data is stored in tables that are linked to each other using relationships. Data is stored in tables made up of rows, which represent entries, and columns, which store and categorize specific types of information. Relationships are established through Primary and Foreign keys.

SQL, or Structured Query Language, is the language that we use to work with RDBSM’s. SQL allows us to perform CRUD operations (create, read, update and delete) through a universal language that is mostly consistent across multiple different RDBSM’s, such as Oracle, PostgreSQL, Microsoft SQL Server and of course MySQL.

MySQL

So what makes MySQL so popular? Let’s explore this database in terms of three components: structure, storage and scalability.

MySQL, like other RDBSM’s, stores information in tables. In this example, our table consists of rows and columns, the columns correspond to the types, and the rows correspond to the individual entities that exist in the table. In a SQL table, you must have a primary key, which corresponds to the unique identifier that identifies a specific row. SQL tables also have attributes which correspond with general data about the record. You can also have foreign keys, which are links to other tables.

SQL databases also enforce constraints. In this example, the AccountId variable is only allowed to be a string, the CreationDate is only allowed to be a date, and the CountryId is only allowed to be an integer. These constraints make it so that operations will fail if the user tries to input a data type that does not align with what’s specified in the table. This constraint forces consistency among tables.

Since tables can use foreign keys to link to other tables, there is a high degree of flexibility in the kinds of queries we can conduct on a mySQL database.

Example of a mySQL model

In terms of storage, the storage pattern in mySQL databases is known as concentrated. There is typically one node that contains an entire copy of the entire database, with no partitioning or segregation of the data in any way.

One of the key disadvantages to MySQL, as well as most RDMS’s, is poor scalability. Users have to scale relational databases on powerful servers that are expensive and difficult to handle.

NoSQL Databases

MongoDB is one of the most popular non-relational, or NoSQL databases. NoSQL databases are non-relational databases that make use of a wide variety of data models; there are NoSQL implementations that make use of tables just like relational databases, as well as implementations that utilize documents or graphs. These databases are built to scale with high performance and are highly regarded for their strong resilience and wide availability. These advantages come with some costs, one of the principal ones being lower flexibility of the queries you are able to conduct. Some popular NoSQL databases are MongoDB, BigTable, RavenDB Cassandra, HBase, Neo4j and CouchDB.

MongoDB

MongoDB is an open-source NoSQL database that was developed in 2007. Its name stems from the word “humongous”, because it’s built to store lots of data in a very efficient way. How does it do this? Let’s explore.

Structure

MongoDB creates and stores data in collections of structures known as documents. These documents contain data in the form of BSON, short for Bin­ary JSON; they are very similar to JavaScript objects but have some added data types. Because of this JSON structure, data between web apps and servers is able to be exchanged in a more human readable format. The schema-free implementation of MongoDB allows data to easily be inserted without any predefined structures. The format or data model can be changed easily at any time, without disrupting the application.

MongoDB stores the data in the BSON type manner.

Scalability

One of the key advantages of MongoDB is that it can also be scaled within and across multiple distributed data centers. This delivers a new level of availability and scalability that was formerly unachievable with relational databases. MongoDB scales efficiently with no downtime as deployments increase in terms of data volume and throughput, and without altering the application.

Conclusion

In the debate against SQL vs. NoSql databases, there is no clear winner. The best option really depends on the kind of application being built and its specific needs. Companies often employ a mixture of both relational and nonSQL databases to meet their requirements and needs.

Here is a chart from www.simform.com that summarizes some of the key differences between the two.

References

https://www.hadoop360.datasciencecentral.com/blog/advantages-and-disadvantages-of-nosql-databases-what-you-should-k

https://www.mongodb.com/scale/advantages-of-nosql

https://www.techwalla.com/articles/disadvantages-of-a-relational-database