We have only really focused on relational databases where we have the data being organized into tables in a structured manner. We have relationships between the tables where they are dependent on one another. We use SQL to query through the data in a very specific format through the tables, columns, and rows. Each table is made up of one topic or object and the column would represent the data points that need to be stored. The row itself would represent the record of the data points that would be used. This type of relational database structure makes it easy to sort, filter, and compute various calculations with expressive query languages.
A non-relational database is focused more so in a document-oriented structure. As such, all of the information is stored within the document with all of the data that’s listed out about that particular object. This type of non-relational database is one that is less structured and confined in terms of format. It does offer high scalability, flexibility with data models and adaptability to the needs of the organization.
If we are working with data that isn’t clearly defined and organized, we won’t be able to establish those defined tables and relationships in the data set. The information that is gathered in this non-relational database isn’t structured to be segmented into tables and define relationships. Facebook Messenger is a good instance of that to store messages. With so much unstructured information, it has to be stored in a non-relational database for efficiency.
There are four main types of NoSQL databases with document-oriented, key-value stores, wide-column stores and graph stores. The document-oriented databases focus on pairing a key with a complex data structure. It would be similar to storing the information in a Word document and just adding more information into that document. If you need to find information, you would have to search through that document. Key-value stores are databases that uses different keys where each key is only associated with one value. An example would be a dictionary where the word is the key, the value is the definition of the word. This is one of the simplest types of NoSQL databases. Wide-column stores also uses tables, rows and columns similar to a relational database, but the names and format of the columns could vary from row to row in the same table. Graph stores use graph structures to link data through edges, nodes and properties and can be one of the more complex types of NoSQL databases.
These NoSQL databases have a flexible data model which makes it easy to store and combine data of any structure and allow us to dynamically modify the schema without any down time. In contrast, with a relational model, to make changes to the data model, we would have to make planned changes which can take time to implement. Since the NoSQL databases are built on performance and scalability, they are setup to be able to quickly scale out offering unlimited growth in comparison to relational databases. They are also designed for highly available systems so that they can provide a consistent high-quality experience for all users around the world.
Relational databases on the other hand focus on the expressive query language through SQL as an example. They also provide indexes within the database to provide efficient access to data rather than maintained in the application code for non-relational databases. With the relational models, there’s much stronger consistency through the primary and foreign keys that should be able to read what has been written to the database immediately.
Source: Authored by Vincent Tran