No history yet

Introduction to Relational Databases

What is a Relational Database?

Think of a relational database as a highly organized digital filing cabinet. Instead of stuffing papers randomly into drawers, you use a system of labeled folders and dividers. This system ensures you can find exactly what you need, quickly and reliably.

At its core, a relational database stores information in a structured way. Data isn't just thrown into a big pile; it's organized into tables. More importantly, these tables can be linked, or related, to each other. This is what makes them so powerful. By connecting different pieces of information, we can see the bigger picture and uncover valuable insights.

A relational database is a type of database that stores and organizes data points with defined relationships for easy access.

The main purpose of this model is to maintain data integrity and reduce redundancy. Instead of writing down a customer's full address every time they place an order, you store their address once in a customer table and simply link their orders to it. This keeps your data clean, consistent, and easy to manage.

The Building Blocks

Relational databases are built from a few simple, fundamental components: tables, columns, and rows. Understanding these is the first step to mastering how databases work.

Table

noun

A collection of related data held in a structured format within a database. Each table represents a specific type of entity, like customers or products.

Imagine a spreadsheet. A table is like a single sheet, dedicated to one subject. For example, you might have one table for Customers and another for Products.

Column

noun

A vertical field in a table that contains a specific attribute for each record. All entries in a column are of the same data type.

Columns define the characteristics of the data in a table. In our Customers table, we might have columns for CustomerID, FirstName, LastName, and Email.

Row

noun

A single record in a table, representing one complete item. It contains a value for each column in that table.

A row is a single entry. In the Customers table, one row would represent one customer, with their specific ID, first name, last name, and email address laid out across the columns.

CustomerIDFirstNameLastNameEmail
1MariaAndersmaria.a@example.com
2AnaTrujilloana.t@example.com
3AntonioMorenoantonio.m@example.com

In the diagram above, CustomerID is the key that links the two tables. Every order in the Orders table has a CustomerID, which points back to a specific customer in the Customers table. This is the 'relation' in a relational database.

Keeping Data Tidy

Imagine a table that tracks both products and their suppliers. If a supplier provides ten different products, you'd have to enter the supplier's name, address, and phone number ten times. This is not only tedious but also risky. If the supplier moves, you have to find and update all ten entries. Miss one, and your data becomes inconsistent.

This is where data normalization comes in. It's a process for organizing the columns and tables in a database to minimize data redundancy.

Normalization is about breaking down large, unwieldy tables into smaller, more manageable ones and defining the relationships between them.

The goal is to ensure that each piece of data is stored in only one place. In our example, we would create a Suppliers table and a Products table. The Products table would simply contain a SupplierID that links back to the correct entry in the Suppliers table. Now, if a supplier's address changes, you only have to update it in one spot.

This process is guided by a set of rules called normal forms. While there are several, most databases are designed to meet the Third Normal Form (3NF), which provides a good balance between reducing redundancy and maintaining practical performance.

For most practical business applications, achieving Third Normal Form (3NF) provides a robust balance between data integrity and performance.

By following these principles, you create a database that is efficient, reliable, and easy to maintain over time.

Quiz Questions 1/6

What is the primary characteristic of a relational database?

Quiz Questions 2/6

What are two primary goals of the relational database model?

These foundational concepts are the bedrock of nearly all modern database systems. Mastering them is the first step toward working with powerful database tools.