MySQL is the world's most popular open-source relational database — the "M" in the classic LAMP stack and the store behind countless web apps. It speaks SQL, so the querying you learn in the SQL course applies directly; this course focuses on the MySQL server itself: creating databases, its data types, keys, and its performance tools.
What is MySQL?
A relational database stores data in tables of rows and columns, with relationships between tables. MySQL is the server that holds those tables and answers SQL queries. You talk to it from a terminal client, a GUI like MySQL Workbench, or from application code.
Connecting
From the command line, connect with the mysql client:
mysql -u root -p # -u user, -p prompts for the password# then, at the mysql> prompt:SHOW DATABASES;USE mydb;SHOW TABLES;
Databases & tables
Create a database, switch into it, then define tables. A table declares each column's name, type and constraints:
CREATE DATABASE albero;USE albero;CREATE TABLE students (id INT AUTO_INCREMENT PRIMARY KEY,name VARCHAR(100) NOT NULL,email VARCHAR(150) UNIQUE,enrolled DATE,package DECIMAL(5,2) DEFAULT 0.00,created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP);
PRIMARY KEYuniquely identifies each row;AUTO_INCREMENTfills it automatically.NOT NULLrequires a value;UNIQUEforbids duplicates;DEFAULTsupplies a fallback.
Data types
Picking the right type keeps data correct and storage small:
| Type | Use for |
|---|---|
INT / BIGINT | Whole numbers, ids |
DECIMAL(p,s) | Exact money/measures (never FLOAT for money) |
VARCHAR(n) | Short, variable-length text |
TEXT | Long text (articles, notes) |
DATE / DATETIME | Dates and timestamps |
BOOLEAN | True/false (stored as TINYINT) |
ENUM(...) | One value from a fixed set |
Practice
Create an albero database with a programmes table (id, name, duration_months, fee) and a students table. Choose sensible types and constraints, then DESCRIBE each table to inspect it.
Key takeaways
- 01MySQL is an open-source relational database server that speaks SQL.
- 02Connect with the mysql client (or Workbench); CREATE DATABASE then USE it.
- 03Every table should have a PRIMARY KEY — usually an AUTO_INCREMENT INT id.
- 04Constraints (NOT NULL, UNIQUE, DEFAULT) keep data valid at the database level.
- 05Match the type to the data: DECIMAL for money, VARCHAR for short text, DATE/DATETIME for time.
