Skip to content
  • What is SQL? · SQL

What is SQL?

LearnViaNotes @learnvianotes· 2 min read

SQL (Structured Query Language) is the standard language for defining, querying and changing data in relational databases — you describe what you want, the database works out how.

Tables, rows and columns

A table has a fixed set of named, typed columns and any number of rows. Every row should be identifiable by a primary key.

SQL
SELECT emp_id, name, salary
FROM employees
WHERE salary > 100000
ORDER BY salary DESC;
Output
emp_id | name  | salary
-------+-------+-------
1      | Asha  | 150000
2      | Ravi  | 120000
5      | Priya | 110000

Read it as English: give me the id, name and salary of employees earning over 1,00,000, highest first. There is no loop, no index handling, no file access — the query optimizer decides how to fetch the rows.

Declarative vs procedural

Relational vocabulary

Formal termEveryday termMeaning
RelationTableA set of tuples with the same attributes
TupleRow / recordOne entity, e.g. one employee
AttributeColumn / fieldOne property, e.g. salary
DomainData type (+ constraints)The allowed values of an attribute
DegreeNumber of columnsemployees has degree 7
CardinalityNumber of rowsemployees has cardinality 10
SchemaStructureTable definitions, types, constraints (not the data)

Why relational databases?

What is the difference between SQL and MySQL?

What does “declarative” mean for SQL?

Free for students and teachers

Write notes like this one

Cards for every idea, quizzes and flashcards, read aloud — on the web and your phone.

Something wrong with this note? Open it to report