What is a Database?

A database is a structured way to store, organize, and retrieve data. Instead of a pile of books scattered on the floor, think of it as a library with a catalog system. Everything has a place. Everything is organized. You can find what you need in milliseconds.

๐Ÿ“š The Library Analogy:
  • No system: Books everywhere. To find a book, you search the entire floor.
  • With a database: Books organized by genre, author, ISBN. The catalog tells you exactly where each book is.

A database does the same for data: it organizes information so you can ask questions ("Find all customers in Nairobi") and get answers instantly.

Tables โ€” The Building Blocks

At the heart of every database is a table. A table is like a spreadsheet tab. It has a name and stores one type of thing. For example:

Here's what a real customers table looks like at QuickCart, an Indian quick-commerce platform:

customer_id first_name last_name email city
1 Priya Sharma priya@quickcart.in Hyderabad
2 Arjun Patel arjun@email.com Bangalore
3 Wanjiku Mwangi wanjiku@email.co.ke Nairobi
4 Jake Morrison jake@shopstream.com Austin
5 Amina Hassan amina@freshbasket.ke Nairobi

That's a real table. It stores customer records. Each row is a person. Each column is a piece of information about that person.

Rows and Columns

Every table has two dimensions:

In the table above, Priya Sharma is one row (the second row). Her first_name, last_name, email, and city are the columns that describe her.

๐Ÿ’ก Think of it like a form: Each row is like filling out a paper form about a customer. Each column is a field on that form.

Primary Keys โ€” Every Row Needs an ID

Look at the table again. The first column is customer_id. This is the primary key.

A primary key is a unique identifier for each row. It's like a passport number โ€” no two people share one. It guarantees that each row can be found and distinguished.

Why do we need this? What if two customers named Priya Sharma both live in Hyderabad? Without a primary key, we couldn't tell them apart. With customer_id = 1, we know exactly who we're talking about.

โš ๏ธ What happens without a primary key?

Imagine a database without IDs. You query: "Find Priya Sharma's orders." The system returns 3 customers named Priya Sharma. Which one is the right one? This is chaos. Primary keys prevent this.

Data Types โ€” What Can a Column Hold?

Every column has a data type. The data type says: "This column only stores this kind of data." Here are the common types:

๐ŸŽฏ Why data types matter: A database enforces rules. You can't store text in an INTEGER column. You can't store "hello" in a DECIMAL column. This keeps data clean and prevents mistakes.

Relationships โ€” Tables That Talk to Each Other

A single table is useful. But databases become powerful when tables talk to each other.

Here's how: An orders table has a column called customer_id. This column points back to the customers table.

customers

customer_id

first_name

email

โ†’

orders

order_id

customer_id โญ

order_date

The customer_id in the orders table is called a foreign key. It links an order to its customer. This is why it's called a "relational" database โ€” the tables have relationships.

๐Ÿ“– Example:

Priya Sharma (customer_id = 1) places an order. The order goes into the orders table with order_id = 101 and customer_id = 1. Now we know that order 101 belongs to customer 1 (Priya). If we need her email, we look it up in the customers table. One source of truth.

Spreadsheet vs Database

You might be thinking: "Isn't this just a spreadsheet?" Close, but not quite. Here's the difference:

๐Ÿ“Š Spreadsheet

  • Anyone can type anything
  • No rules or validation
  • Gets messy quickly
  • Hard to scale to millions of rows
  • One person at a time
  • Great for small datasets

๐Ÿ—„๏ธ Database

  • Enforced data types
  • Constraints and rules
  • Stays organized
  • Handles billions of rows
  • Many users simultaneously
  • Built for scale and reliability

A database is a spreadsheet that grew up. It learned to say "no" to bad data and "yes" to scale.

What We'll Build

Throughout this track, we'll work with a fictional e-commerce schema across three regions:

The schema has these tables:

customers

customer_id (PK)

products

product_id (PK)

โ†“

orders

order_id (PK)

customer_id (FK)

order_items

order_id (FK)

product_id (FK)

PK = Primary Key | FK = Foreign Key

Knowledge Check

Test your understanding of database fundamentals.

Question 1 of 5
What uniquely identifies each row in a table?
Question 2 of 5
What data type would you use for a price like โ‚น450.00?
Question 3 of 5
What does NULL mean in a database?
Question 4 of 5
What connects an order to its customer across tables?
Question 5 of 5
How is a database different from a spreadsheet?
0
/5
Africa & India's Best AI Academy
๐Ÿค– AI-first ๐ŸŽ“ Placement Assistance

Now you see the mental model.

Join the Best AI Program: The AI-Era Data Engineer โ€” 5 months, fully online, with placement assistance. Week 1 is free.

Explore The AI-Era Data Engineer โ†’