What is SQL and Why It Matters
What is SQL?
SQL (Structured Query Language) is the standard language for interacting with relational databases. It lets you create, read, update, and delete data stored in tables. Whether you are building a web application, analysing data, or managing a back-end system, SQL is the lingua franca of data.
SQL is not tied to a single database engine. The same core syntax works in PostgreSQL, MySQL, SQLite, Microsoft SQL Server, and many others. Learning SQL once means you can work across virtually every relational database you will ever encounter — something emphasised heavily in the CPCODELAB backend curriculum.
Relational Databases in a Nutshell
A relational database organises data into tables (also called relations). Each table has named columns (attributes) and rows (records). Relationships between tables are expressed through shared key values, which keeps data consistent and avoids duplication.
- Table — a named collection of rows that share the same columns
- Column — a named attribute with a specific data type (e.g.,
TEXT,INTEGER) - Row — a single record in a table
- Primary Key — a column (or set of columns) that uniquely identifies each row
- Foreign Key — a column that references the primary key of another table
Our Example Schema
Throughout this course we will use three tables: students, courses, and enrolments. Here is how they are defined.
-- students: one row per student
CREATE TABLE students (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
city TEXT,
age INTEGER
);
-- courses: one row per course
CREATE TABLE courses (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
category TEXT,
price NUMERIC(8,2) DEFAULT 0
);
-- enrolments: links students to courses
CREATE TABLE enrolments (
id INTEGER PRIMARY KEY,
student_id INTEGER NOT NULL REFERENCES students(id),
course_id INTEGER NOT NULL REFERENCES courses(id),
enrolled_at DATE NOT NULL,
score INTEGER
);You do not need to memorise the exact schema right now. We will revisit it in every lesson so it will become second nature.