As we have mentioned in our article about cloud databases, there are different database types depending on how they operate. This is important, as these different types are designed for different applications. In this article, we will talk about two main types of databases today: relational and non-relational databases.
According to Oracle, a relational database is a type of database that stores and provides access to data points that are related to one another. In order to easily track related data, a relational database stores data points along with their attributes in the form of tables. The relationship between each piece of data can easily be determined from its location in the table.
To explain how relational databases work, let us use the spreadsheet as an analogy. For spreadsheets, we store related entries (for example, all sales transactions) in a single sheet. For a single sheet, we define the first column as the name or ID of the data points to be included in each row. Each succeeding column contains the attributes of these data points and are labeled accordingly.
A relational database works similarly:
Each row that contains a data entry is called a tuple.
The columns are called attributes.
The entire table (or sheet) is then called a relation.
A relational database will contain at least two relations. These relations contain a different set of attributes but have the same column containing the name or ID, which serves as the connection between seemingly dissimilar relations.
The use of tables, according to Oracle, made it possible to quickly search information through the relations stored in the database. This is why relational databases are one of the most common types of databases in use. One of the most popular implementations of a relational database is the Structured Query Language, or SQL.
Provides support for ACID (Atomicity, Consistency, Isolation, and Durability) transactions
Data is easily stored and retrieved using SQL queries
The structure can be scaled up quickly because adding data without modifying existing data is simple
Creating limits on what certain user types can access or modify is built into the structure of a relational database
While the weaknesses are as follows:
Relational databases have a hard time with unstructured data
Representing real world entities in context is difficult in the bounds of a relational database
“Sliced” data has to be reassembled from tables into something more readable
The fixed schema doesn’t react well to change
They tend to be more expensive to set up and grow
Sharding (where data is horizontally partitioned and distributed across a collection of machines) relational databases while maintaining ACID compliance can be a challenge
InfoWorld concludes that relational databases work best for highly structured data and automation of processes.
To clarify further why non-relational databases exist, let us do a quick recap of what structured and unstructured data means.
Structured data is a type of data that is clearly defined and systematically stored in an easily-searchable format. Examples of structured data include personal information records, business transaction records, and customer records.
Unstructured data is a type of data that is not easily searchable and is stored in a variety of formats that cannot be easily processed. Examples of unstructured data include document files, images, and videos.
Databases were initially developed to store structured data.Relational databases, due to their structurally-optimized capabilities, were the perfect method for storing such data. However, recent developments in modern industries have led to a greater need for storing unstructured data types. Non-relational databases were developed for this purpose. We will highlight five types of non-relational databases:
Wide-column stores are a type of non-relational database that still store data in the form of tables, but with entries in rows with varying numbers of columns and the data stored in it. Wide-column databases are used with types of data that can be structured but may vary in the amount and type of accompanying information.
Key-value databases are a type of non-relational database that use a set of keys as a reference to the data. A single key refers to a single piece of data. Key-value databases are often used to store huge amounts of a single type of data, as opposed to relational databases where an entry has an ID and has a set of associated data that is stored in different tables.
Document databases are a type of non-relational database that store a single tuple to a single document, as opposed to a table containing all the entries with their data in the case of relational databases. Documents can be in JSON, XML, or other data-oriented format. Each document contains highly-structured data, with its label and corresponding value. Document databases are one of the preferred database types because they are relatively easy to manipulate.
Graph databases are a type of non-relational database that store all data in the form of nodes connected to each other. A dataset is stored in a node while additional data about their relationship to other nodes is stored in so-called “edges”. Graph databases are best for data that is highly interconnected, such as those in social media sites.
Time-series databases are a type of non-relational database that are optimized for quickly storing time-stamped data that arrives quickly in large amounts over a given period of time. An entry to a time-series database consists of a timestamp with a certain type of data attached to it, usually numerical data. Time-series databases are best used for storing time-dependent data, such as financial data.
Seeing that there is a wide variety of database types now available, you would need to determine the type of data that you need to store so you can make a good choice. Below is a quick summary of each type of data along with the database type they are best designed for:
Highly-structured data that can be stored in tables with fixed number of columns: relational database
Structured data but may have a varying number of columns: wide-column stores
Huge amounts of a single type of data: key-value databases
A structured dataset where each tuple is stored separately: document databases
Highly-interconnected data: graph databases
Time-dependent data: time-series databases
Each type of database has its strengths and you can choose the database type that best fits your individual needs.