Aral Code

Getting Started Lesson 2 of 21

The Sample Database — Tindahan ni Aling Nena

Meet the tables used in this course — products, customers, orders, order_items, students and grades — and how they connect through ids.

Every example in this course uses the same small database. Getting to know it now makes every later lesson easier. Run each query to see the full table.

products

The items sold in the store.

SQL products
SELECT * FROM products;
ColumnMeaning
idUnique product number (primary key)
nameProduct name
categoryBread, Drinks, Snacks…
pricePrice in pesos
stockHow many are left

customers

SQL customers
SELECT * FROM customers;

Notice that some phone numbers show NULL, which means "no value". You'll learn how to handle NULL in its own lesson.

orders

Each time a customer buys something, an order is recorded. status is either paid or utang (on credit, to be paid later).

SQL orders
SELECT * FROM orders;

The customer_id column doesn't store the customer's name; it stores their id from the customers table. Order 1 has customer_id 1, which is Maria Santos. This link between tables is called a foreign key.

order_items

An order can contain several products. This table lists what was in each order:

SQL order_items
SELECT * FROM order_items;

For example, order 1 contains product 1 (Pandesal) × 1, product 6 (Coffee) × 4 and product 12 (Eggs) × 6.

How the tables connect

customers.id  ──<  orders.customer_id
orders.id     ──<  order_items.order_id
products.id   ──<  order_items.product_id

One customer can have many orders, and one order can have many items. Splitting data into connected tables like this, instead of one giant table, avoids repeating information. It's called normalization, and it's why these are called relational databases. In the JOIN lessons you'll combine these tables to answer questions like "What did Maria Santos buy?"

students and grades

A second, separate set of tables holds a small class record:

SQL students
SELECT * FROM students;
SQL grades
SELECT * FROM grades;

grades.student_id links each score to a student. Some students are missing a grade in one subject; that's on purpose, for the lessons on NULL and LEFT JOIN.

Listing the tables

In SQLite you can see every table in the database with this query:

SQL All tables in this database
SELECT name FROM sqlite_master WHERE type = 'table';

In MySQL, the same is done with SHOW TABLES;. That's one of the small differences between database systems.

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. What does orders.customer_id store?
2. What does "utang" mean in the status column?
3. Why is the data split into several tables?
4. What does NULL mean in a table?

By Sir Reyel · Last updated 2026-12-04