No history yet

Introduction to Databases

Organizing Information

At its core, a database is just an organized collection of data. Think of it as a digital filing cabinet. Instead of paper folders, you have a system designed to store, manage, and retrieve huge amounts of information efficiently and safely.

Why do we need them? Imagine trying to find a specific customer's order from a list of millions, written on paper. It would be a nightmare. A database lets you pull up that exact order in a fraction of a second. They power everything from online shopping and social media feeds to bank records and library catalogs. Their main job is to bring order to data chaos.

A database makes data easy to access, manage, and update.

The Relational Model

The most common type of database is a relational database. The name sounds technical, but the idea is simple. It organizes data into tables, and the “relation” part means it’s designed to recognize relationships between the information stored in different tables.

For example, an online store might have one table for Customers and another for Orders. A relational database can link a specific customer to all the orders they've placed. This structure is intuitive because it mirrors how we often group things in the real world.

Lesson image

Data in a relational database is stored in tables, which are made up of rows and columns.

Table

noun

A collection of related data held in a structured format, consisting of columns and rows. For example, a table could hold all the information about a company's employees.

Each table has columns and rows.

Columns define the categories of information (like FirstName, LastName, Email).

Rows contain the actual data for one specific item (like one person's information).

Connecting the Tables

Having organized tables is great, but the real power of a relational database comes from connecting them. We do this using special columns called keys.

A primary key is a column that contains a unique identifier for each row in a table. Think of it like a Social Security Number for a person or a serial number for a product. No two rows in the same table can have the same primary key. This ensures we can always pinpoint one specific record without any confusion.

A primary key uniquely identifies each record in a table. It cannot be null or duplicated.

Now, how do we link two tables? That's where the foreign key comes in. A foreign key is a column in one table that refers to the primary key of another table. It's the 'glue' that connects your data.

Let's say we have a Students table and a Courses table. If we want to know which students are enrolled in which courses, we can create a third table called Enrollments. This table would have a foreign key for StudentID (linking to the Students table) and another for CourseID (linking to the Courses table).

By using primary and foreign keys, we create a web of related information that is efficient, reliable, and easy to navigate.

Time to check your understanding.

Quiz Questions 1/5

What is the fundamental purpose of a database?

Quiz Questions 2/5

How does a relational database organize data?

These building blocks—tables, rows, columns, and keys—are the foundation of how relational databases work. Understanding them is the first step toward managing data effectively.