← SQL roadmap

Topic 1 of 52 · Beginner

Databases, Tables & SQL

What a relational database is and how SQL talks to it.

Concept

A relational database stores data in tables. Each table has columns (the fields, each with a type) and rows (one record each). Tables are linked through key values.

SQL (Structured Query Language) is the declarative language used to define, read and change that data. You describe what you want and the database decides how to fetch it.

SQL commands are grouped into DDL (CREATE, ALTER, DROP), DML (INSERT, UPDATE, DELETE), DQL (SELECT), DCL (GRANT, REVOKE) and TCL (COMMIT, ROLLBACK).

Cheat sheet

GroupCommandsPurpose
DDLCREATE, ALTER, DROP, TRUNCATEDefine structure
DMLINSERT, UPDATE, DELETEChange rows
DQLSELECTRead rows
DCLGRANT, REVOKEPermissions
TCLCOMMIT, ROLLBACK, SAVEPOINTTransactions

Code (SQL · MySQL 8)

CREATE DATABASE shop;
USE shop;

SHOW TABLES;
SELECT VERSION();

Remember

  • A table = columns (schema) + rows (data).
  • SQL is declarative: say what, not how.
  • Keywords are case-insensitive; string values usually are not.

Interview questions

What is the difference between a DBMS and an RDBMS?

A DBMS stores and manages data in any form. An RDBMS stores data in related tables, enforces keys and constraints, and is queried with SQL.

Name the SQL sub-languages.

DDL, DML, DQL, DCL and TCL — define structure, change data, query data, control access and control transactions.

Practise SQL with the AI mentor

Lesson test

Take an 8-question test on “Databases, Tables & SQL” — concepts, output prediction, bug spotting and interview questions.

Can't find a SQL topic you need for exams or placements? Request it and we'll add it.