ELI5: the relational vs non-relational database
A database is – as you might have guessed – a collection of data held on a computer. But did you know that in the database world, there are two main types of database?
These are the relational database and the non-relational database. But what does this mean, exactly?
Here, we explore the relational vs non-relational database divide in a quick ‘explain like I’m 5’ overview. What are the differences between these two database types?
What is a relational database?
The first side of the relational vs non-relational database exploration looks at relational databases. IBM’s E. F. Codd coined the term ‘relational database’ in his 1970 paper “A Relational Model of Data for Large Shared Data Banks”.
A relational database, as the name suggests, shows the relationship between data points. This is known as a ‘relational model of data’. The data in a relational database fits nicely into structured tables. (Think an Excel spreadsheet, for instance.)
This means that data is organised into rows and columns. The rows represent a data entry and the columns categorise the information. For example, entry number, name, address, age, and so on. The relationships between this data (and the different tables) are called a schema.
From there, you can make queries and extract data as needed. Relational databases are also known as SQL databases because they use structured query language (SQL). This is a programming language that allows you to execute queries, retrieve and also edit data. (I.e. deleting, updating, and adding new information.)
What is a non-relational database?
The other side of the relational vs non-relational database question is the non-relational database.
A non-relational database, unlike its counterpart, does not show the relationship between data points. It doesn’t use tables of rows and columns. Rather, it’s a way of storing unstructured data. For example, documents, images, blog content, etcetera, which cannot be easily sorted into categories.
Non-relational databases are also known as NoSQL databases. NoSQL stands for ‘not only structured query language’. This is because while they can support SQL, they aren’t limited to this type of language.
There are four subtypes of the non-relational database.
A document-oriented non-relational database stores and manages information in documents. That is, data is stored as documents.
- Key-value stores
Key-value stores are among the simplest forms of the non-relational database. It stores data as a name (‘key’) and a value. So, each ‘key’ is only associated with one value in a set of data. The advantage of this is that key-value stores often take much less memory to store the same database.
- Wide-column stores
Wide-column stores use tables, rows and columns. However, one column can hold multiple data points. (Which, in a relational database would take up multiple rows/ more space).
- Graph stores
Graph stores are a type of non-relational database that map data into graphs. This means data is stored as ‘nodes’ (a data point) and ‘edges’ (the connections between the nodes/data points.)
A family tree is a simplistic example of a graph database.
Relational vs non-relational database
The answer to the relational vs non-relational database debate on an implementation level depends on the type of data you’re storing, the amount of data you’re storing, and the resources available to you.
If you can easily sort the data into rows and columns, then a relational database is likely the right choice for you.
As the amount and complexity of the data grows, the more likely it is that a non-relational database suits your needs.