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.
SELECT * FROM products;
| Column | Meaning |
|---|---|
id | Unique product number (primary key) |
name | Product name |
category | Bread, Drinks, Snacks… |
price | Price in pesos |
stock | How many are left |
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).
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:
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:
SELECT * FROM students;
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:
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. 🙂
By Sir Reyel · Last updated 2026-12-04