Duration: 2 hours | Theory: 30 min | Practice: 90 min
Slides 1-5 introduce why databases beat files for data storage. Students see the "big picture" roadmap, then you jump into DDL/DML concepts (slides 6-10). The real work starts around slide 11 where they create their first tables.
Skip the iframe on slide 2 - it's a draw.io diagram that doesn't work well in presentation mode. Just explain verbally: "databases centralize data, files scatter it everywhere."
Send students a checklist 24 hours before:
This saves 30 minutes of "wait while it downloads" during class. If students didn't prepare, have them pair with someone who did.
After the title slide, show slide 3 (databases vs files diagram). Ask students: "Who's used Excel for data? What broke when the file got big?" Use their answers to intro the three database languages on slides 6-7.
Don't spend more than 2 minutes per slide here. The goal is to get them curious, not to memorize DDL/DML/DCL definitions.
Slide 8 introduces tables, rows, columns. Draw this on a whiteboard alongside the slide - students understand better with a hand-drawn table than the formal SVG diagrams.
Slides 11-12 cover constraints and keys. Keep it brief: "PRIMARY KEY = unique ID, FOREIGN KEY = link to another table." You'll reinforce this later when they build actual tables.
Now close the slides and open MySQL. Walk through creating a database step by step:
CREATE DATABASE lecture1_demo;
USE lecture1_demo;
CREATE TABLE customers (
customer_id INT PRIMARY KEY AUTO_INCREMENT,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
email VARCHAR(100) UNIQUE
);
INSERT INTO customers (first_name, last_name, email)
VALUES ('Alice', 'Johnson', 'alice@test.com');
SELECT * FROM customers;
-- Deliberately try to break it
INSERT INTO customers (first_name, last_name, email)
VALUES ('Bob', 'Smith', 'alice@test.com');
-- Error! Duplicate email - this is GOOD, show them the error
Explain each line as you type it. When the duplicate email fails, celebrate it: "See? The database stopped me from adding bad data. Files can't do that."
Give students this challenge (no slide for this, just verbally):
Build a library database with:
Then insert 3 books and 3 members, and write queries to find books published after 2020.
Walk around while they work. Common mistakes:
USE database_name; before CREATE TABLEINT for email or VARCHAR for numbersINSERT INTO books VALUES ('1', 'Title') instead of (1, 'Title')This exercise teaches constraints by letting students hit errors:
After they've tried, discuss: "These errors aren't bugs - they're features. The database is protecting your data."
Now jump to the MySQL installation slides at the end. Walk through together:
Slide 26: Initialize MySQL
cd C:\mysql\bin
mysqld --initialize-insecure --console
Slide 27: Start the server (keep this terminal open!)
mysqld --console
Slide 28: Connect (new terminal)
mysql -u root
SHOW DATABASES;
Students who finish early: install DBeaver (slides 29-33). But command line is sufficient for now.
"I get 'command not found' when running mysql"
They're not in the bin directory. Have them cd C:\mysql\bin first (Windows) or add MySQL to PATH.
"Error: Can't connect to MySQL server"
The mysqld server isn't running. Check if they have the server terminal open with mysqld --console.
"Table already exists" error
They ran CREATE TABLE twice. Show them: DROP TABLE table_name; then try again.
Personal movie collection database with at least 5 movies. Must include: title, director, year, genre, rating (0-10), watched (yes/no). Write queries to find unwatched movies and movies rated above 7.
Next lecture preview: "We'll learn to design databases properly before coding. You'll draw ER diagrams for complex systems like e-commerce sites."