LearnFrenzy
Sign in Take a free test

Introduction to SQL · Lesson 1 of 30

What Is SQL? Databases, Tables and Keys

4 min read Updated Nov 7, 2026 Saurabh Samir

Every app you use stores data somewhere: your bank balance, your orders, your messages, your exam results. Most of that data lives in relational databases, and the language used to work with them is SQL (Structured Query Language, pronounced "S-Q-L" or "sequel"). It's one of the few skills asked for in almost every tech role – developers, data analysts, testers, data engineers and even product managers use it daily.

In this lesson

  • What a database and a DBMS are
  • Tables, rows and columns
  • Primary keys, foreign keys and relationships
  • The groups of SQL commands, and popular databases

Database, DBMS and SQL

How the pieces fit

  1. Your app or yousends SQL: SELECT name FROM customers WHERE city = 'Pune'
  2. DBMS (MySQL, PostgreSQL, SQL Server…)parses, plans and runs the query safely
  3. Databasethe stored data – tables on disk, indexes, logs
  • A database is an organised collection of data.
  • A DBMS (database management system) is the software that stores it and answers requests. A relational DBMS (RDBMS) stores data in related tables.
  • SQL is the standard language for asking an RDBMS to read or change data. You describe what you want; the database works out how to get it.

Tables, rows and columns

A table looks like a spreadsheet with strict rules. Each column has a name and a data type; each row is one record.

SELECT customer_id, name, city FROM customers LIMIT 4;

Output

+-------------+------------+-----------+
| customer_id | name       | city      |
+-------------+------------+-----------+
|           1 | Asha Verma | Pune      |
|           2 | Ravi Kumar | Delhi     |
|           3 | Meera Nair | Kochi     |
|           4 | Kiran Rao  | Bengaluru |
+-------------+------------+-----------+
TermAlso calledExample
Tablerelationcustomers
Rowrecord, tupleAsha Verma from Pune
Columnfield, attributecity
Data typedomainVARCHAR(40), INT, DATE

Keys and relationships

A primary key uniquely identifies each row – no two customers share a customer_id, and it can't be empty. A foreign key is a column that points to the primary key of another table, linking the tables together.

SELECT order_id, customer_id, order_date, status FROM orders LIMIT 3;

Output

+----------+-------------+------------+-----------+
| order_id | customer_id | order_date | status    |
+----------+-------------+------------+-----------+
|      101 |           1 | 2025-08-02 | delivered |
|      102 |           2 | 2025-08-05 | delivered |
|      103 |           1 | 2025-08-19 | delivered |
+----------+-------------+------------+-----------+

orders.customer_id is a foreign key: order 101 and order 103 both belong to customer 1, Asha. Instead of copying Asha's name and email into every order, the database stores them once and links to them – that's the core idea of a relational database.

One customer, many orders (a one-to-many relationship)

  1. customerscustomer_id 1 = Asha Verma (primary key)
  2. orders101 and 103 have customer_id 1 (foreign key)
  3. A JOIN brings them together"Asha placed orders 101 and 103" – chapter 5

The SQL command groups

GroupPurposeCommands
DQL – queryread dataSELECT
DML – manipulationchange rowsINSERT, UPDATE, DELETE
DDL – definitioncreate and change structureCREATE, ALTER, DROP, TRUNCATE
DCL – controlpermissionsGRANT, REVOKE
TCL – transactionsgroup changes safelyCOMMIT, ROLLBACK, SAVEPOINT

SQL is a standard, so what you learn works almost everywhere. Each product adds small differences ("dialects").

DatabaseWhere you'll meet it
MySQL / MariaDBweb apps, WordPress, startups – this course uses MySQL 8
PostgreSQLmodern back-ends, analytics; very standards-compliant
SQL Serverenterprises using Microsoft technology
Oraclebanks, telecoms, large enterprises
SQLitemobile apps, browsers, small tools – a database in one file

SQL vs NoSQL

NoSQL databases (MongoDB, Redis, DynamoDB) store documents, key-values or graphs instead of fixed tables. They suit some workloads, but relational databases and SQL remain the default for most business data – and SQL skills transfer to analytics tools like BigQuery, Snowflake and Spark SQL.

Practice

Quick check

What is the difference between a database and a DBMS?

The database is the stored data; the DBMS is the software (like MySQL) that manages it and runs your queries.

Can two rows have the same primary key?

No – a primary key must be unique and not NULL.

What does a foreign key do?

It links a row to a row in another table by referring to that table's primary key, and the database enforces that the referenced row exists.

Which command group does UPDATE belong to?

DML – data manipulation.

Summary

  • A relational database stores data in tables of rows and columns; SQL is the language to query and change it.
  • Primary keys identify rows; foreign keys link tables into relationships.
  • SQL commands group into DQL, DML, DDL, DCL and TCL; the same SQL works across MySQL, PostgreSQL and others.

Finished this lesson?

Mark it complete to track your progress, then carry on with the next lesson.

Next lesson

Search LearnFrenzy

Esc

Quick links