Learning Library

← Back to Library

Relational vs Non-Relational Databases

Key Points

  • Relational databases store data in structured, interconnected tables where each table represents a single entity such as customers or orders.
  • Each record within a table is uniquely identified by a primary key (e.g., customer ID, order ID), enabling precise retrieval and reference.
  • Relationships between tables are created by linking foreign keys (e.g., an order record includes the customer ID to indicate who placed it), allowing complex queries across entities.
  • This tabular, schema‑driven approach ensures data integrity and consistency but requires a predefined structure, contrasting with the flexibility of non‑relational (NoSQL) databases.

Full Transcript

# Relational vs Non-Relational Databases **Source:** [https://www.youtube.com/watch?v=E9AgJnsEvG4](https://www.youtube.com/watch?v=E9AgJnsEvG4) **Duration:** 00:08:06 ## Summary - Relational databases store data in structured, interconnected tables where each table represents a single entity such as customers or orders. - Each record within a table is uniquely identified by a primary key (e.g., customer ID, order ID), enabling precise retrieval and reference. - Relationships between tables are created by linking foreign keys (e.g., an order record includes the customer ID to indicate who placed it), allowing complex queries across entities. - This tabular, schema‑driven approach ensures data integrity and consistency but requires a predefined structure, contrasting with the flexibility of non‑relational (NoSQL) databases. ## Sections - [00:00:00](https://www.youtube.com/watch?v=E9AgJnsEvG4&t=0s) **Relational Databases: Tables and Keys** - The speaker outlines how relational databases store data in interconnected tables, using primary keys to uniquely identify each record. - [00:03:14](https://www.youtube.com/watch?v=E9AgJnsEvG4&t=194s) **Customer‑Order Relationship via Foreign Keys** - The speaker explains how linking a customer table’s primary key to an order table’s foreign key lets you identify which customers placed which orders, illustrating relational database benefits like data consistency, ease of management, and enhanced security. - [00:06:25](https://www.youtube.com/watch?v=E9AgJnsEvG4&t=385s) **Why Choose Non-Relational Databases** - The speaker highlights flexibility, horizontal scalability, and cost efficiency as key reasons customers prefer non-relational databases over relational ones for modern applications, while noting relational databases suit structured, traditional workloads. ## Full Transcript
0:00Hi, everyone. 0:01Today I'm going to be talking to you about relational versus non-relational databases. 0:04These are two different ways in which clients store the data that they have and operationalize it. 0:09And we know there is so much data that is coming into every single company today 0:12that it's important that customers have options for how they want to store that data. 0:17So, let's start with relational databases. 0:20Relational databases are a very structured way to store your data. 0:25But to really understand a relational database, first we need to understand a table. 0:30So all the data is stored in tables and those tables are connected to each other. 0:34That's why we have the name "relational" and we see a relation in the name 0:38because all these tables connect to each other. 0:40They all have relations with each other. 0:42So let's start with one table. 0:45We have our customer. 0:48So each table revolves around a single entity. 0:52And with our customer, there is a lot of different information that we would want to know about them, right? 0:56We'd want to know what their first name is, 1:01their last name, 1:05maybe their date of birth, their email, 1:09and etcetera, etcetera, whatever other information would be relevant to know about the customer. 1:14But we might also have customers that have the same first name or the same last name, 1:18and we need a way to uniquely identify each customer. 1:21So that's why we have our primary key, which is our customer ID. 1:26And this is a unique identifier for each record in this table. 1:30But like I said, with relational databases, we want to view each table as it connects to other tables. 1:35So let's think about what a customer does. 1:37A customer places an order, right? 1:39So an order is actually a separate entity that would connect to our customer table. 1:44So let's draw out our order table. 1:48And what would we want to know about an order? 1:50We'd want to know maybe what time it was placed, 1:53what items are in it, and whatever else you think is relevant to know here. 1:59But again, like with the customer ID, we need a unique way to identify each order. 2:03So we have another primary key here called an order ID. 2:08And if we look at each of these tables and we look at the data in them, we can really see how they connect to each other. 2:15So let's take a customer table, for example. 2:19We know we have all these different pieces of information that are relevant to know about the customer. 2:24So I'm going to start with the customer ID. 2:28And then we have their first name, last name, etc.. 2:36So like we said, each customer ID is unique. 2:39There's only one for each record in the database. 2:42So we have our first customer, let's call him John Doe. 2:48Our second customer, let's say, is named Jane Smith. 2:54And third customer. 2:57We can just continue populating information about every single customer that we have. 3:03And then with our order table, we start with our order ID, 3:11and we have other information that we want to know, right? 3:14Time, items, etc.. 3:17But what we also need to know is which customer placed what order, right? 3:21So, in order to do that, we actually connect the customer ID to the order table. 3:25So we take this information and we move it over here. 3:29So in the customer table, this is the primary key. 3:31But when we move it over, this becomes the foreign key. 3:34So now we can add in our customer ID here. 3:39And we have our first order. 3:40It's placed at this time. 3:42Second order. 3:43Third order. 3:45And looking at our customer ID, let's say that this is 1. 3:49And our second one is 2, our third one is also 2. 3:54And now we can see, through connecting these two databases, 3:57that customer John Doe made the first order. 4:00We see what time, what items. 4:02He also made the second order, and Jane Smith made the third order. 4:06So as we can see with relational databases, this is a very structured way to view the information that's coming into a company. 4:14But with that, there's a lot of benefits that come in. 4:16So one of them is that the structure really ensures data consistency. 4:22And you can see that all the data that we have over here is very consistent, right? 4:27We can see that it's easy to manage that data and easy to get an overview of what is in your database. 4:34This also helps with security. 4:37So, let's say that you are in hospital and you have a lot of patients. 4:40You have information about their medical history, what medications are taking. 4:44That is all protected information. 4:46So through using a relational database, you can encrypt certain tables, 4:49you can hide information, 4:51and you can make sure the right people have access to the right data. 4:54And then finally, we have ease of backup and recovery. 5:00So, because this data is very consistent and at all times it remains consistent, 5:05it's easy to save the database at any point and easily recover from what you recently had. 5:10So this gives us an idea of what a relational database looks like. 5:14Now on the other hand, we have non-relational databases. 5:17So this is a break from the very structured approach of a relational database. 5:22There are a few different types of non-relational databases. 5:25First, we have key value databases. 5:30And this shows data as a key and a value, right? 5:33We have one key that ties to one unique value. 5:37Another key that ties to another unique value. 5:40And you can retrieve these values through plugging in the keys and getting that information back. 5:45We also have column store databases. 5:50And this stores data in separate columns and is optimized for performance. 5:58And then we have graph databases. 6:01So this shows different entities in the database and how they connect to each other in a graphical way. 6:09And finally, we have our document store databases. 6:17So this has data and documents, and a group of documents is called a collection, 6:21and you can essentially retrieve the information as it relates to a single collection. 6:26So you see that there are a lot more options here with the non-relational databases. 6:30And that's really why customers might choose a non-relational option as opposed to a relational one. 6:35There is added flexibility in going with a non-relational database. 6:41So that's really one of the key differentiators and why customers choose non-relational over relational. 6:47And it also has high scalability. 6:52It's easy to scale non-relational databases out horizontally 6:56and this means that they can essentially scale out without adding more resources. 7:03And finally, cost effectiveness. 7:11And this ties back into the scalability, right, because you're not adding more resources, but you're able to scale out and add more data in. 7:18So we see that we have a lot of different ways in which customers can store their information 7:22and make sense of all the data that's coming into the company. 7:25There are different ways that people can leverage both of these databases. 7:29There are different use cases. 7:30People might use relational databases for more traditional workloads. 7:34If you have a point of sale system, if you're tracking a large amount of records and you want to do so in a very structured way, 7:40then relational databases might be what you go for, for that. 7:43But if you're developing a new application, you want added flexibility, 7:47then customers might defer to a non-relational database. 7:50But either way, our clients have options as to how they want to store their data and how they want to best operationalize it. 7:56Thank you. 7:59Thank you. 7:59If you like this video and want to see more like it, please like and subscribe. 8:03If you have any questions, please drop them in the comments below.