Database Basics · Lesson 8 of 112

Database Glossary of Key Terms

What you will learn

  • The meaning of about 50 key terms in one place
  • Which lesson teaches each term in full
  • How terms connect (a key, a constraint, an index, a transaction)
  • How to use a glossary while you study, instead of memorising it

This page is a map, not a replacement for the lessons. Each definition is short on purpose. The number in brackets is the lesson that explains the term properly (for example 5.3 means chapter 5, lesson 3). Terms from the later chapters (10 to 14) are listed by chapter, because those chapters go deeper into what you will meet in real systems.

1. Basics

Term Meaning Lesson
Data raw facts such as 25 or Dhaka 1.1
Information data with meaning in context 1.1
Database an organised collection of data, stored for good and easy to search, check and share 1.1
DBMS database management system: the software that stores the data and answers requests (SQLite, PostgreSQL, MySQL, MongoDB...) 1.3
Client and server the client asks, the server (the DBMS) answers, often over a network 1.5
SQL Structured Query Language, the standard language for asking relational databases questions 1.1, chapter 4
Driver a library that lets a program talk to a DBMS (for Python's SQLite it is the built-in sqlite3) 1.6

2. Structure

Term Meaning Lesson
Table data about one kind of thing, in rows and columns 2.1
Row (record) one item in a table, such as one customer 2.1
Column (field) one property that every row has, such as name 2.1
Data type the kind of value a column holds (integer, text, date...) 2.2
NULL "no value or unknown", which is not the same as zero or an empty string 2.3
Primary key the column (or columns) that identifies each row; unique and never NULL 2.4
Natural key / surrogate key a key made of real data (such as an email) / a made-up one (such as id) 2.5
Candidate key any column set that could serve as the primary key 2.6
Constraint a rule the database enforces itself (NOT NULL, UNIQUE, CHECK, FOREIGN KEY) 2.7
Schema the definition of the tables, columns and rules (also a name for a group of tables in some systems) 2.8

3. Relationships

Term Meaning Lesson
Foreign key a column holding another table's key, which links rows together 3.1
One-to-many one row on one side links to many on the other (one customer, many orders) 3.2
Many-to-many needs a third table, the junction table 3.4
Referential integrity every foreign key points to a row that really exists 3.5
Entity and attribute a thing we keep data about / a fact about it; they become tables and columns 3.6
ER diagram a drawing of entities and their relationships 3.6
Cardinality and optionality how many rows can be linked / whether a link is required 3.7

4. Queries

Term Meaning Lesson
Query a question you ask the database, usually with SELECT 4.1
Filter (WHERE) keeps only the rows that match a condition 4.2
Aggregate and GROUP BY one result from many rows (count, sum, average), per group 4.4
Join combines rows from two tables using a matching column 4.5
View a saved query that you use like a table 4.7

5. Design

Term Meaning Lesson
Anomaly a fault caused by repeated data (an update, insert or delete that leaves data inconsistent) 5.1
Functional dependency when one column's value decides another's 5.2
Normalization splitting tables to remove repeated data (1NF, 2NF, 3NF, BCNF) 5.3 to 5.6
Denormalization repeating data on purpose, usually to read faster 5.7
Migration a controlled, versioned change to the structure of a live database 8.7

6. Transactions

Term Meaning Lesson
Transaction a group of changes treated as one unit: all happen or none 6.1
Commit and rollback make the changes permanent / undo them 6.2
ACID atomicity, consistency, isolation, durability: the four promises of a transaction 6.3
Isolation level how much concurrent transactions can see of each other's work 6.5
Lock and deadlock a claim on data / two transactions waiting for each other forever 6.6

7. Speed

Term Meaning Lesson
Index an extra structure that lets the database find rows without reading the whole table 7.1
Full scan reading every row of a table 7.1
Composite index an index on more than one column; the column order matters 7.5
Query plan the steps the database chose to answer a query (EXPLAIN) 7.6

8. Safety

Term Meaning Lesson
Backup and restore a copy of the data / bringing the data back from a copy; a backup you never tested is a hope 8.1 to 8.3
Permission (privilege) and role what a user may do / a named bundle of permissions 8.4
SQL injection an attack where user input is mistaken for SQL; prevented with parameters 8.5

9. Kinds of databases and big systems

Term Meaning Lesson
Relational database data in related tables, queried with SQL 9.1
Document database stores flexible, nested documents (for example JSON) 9.2
Key-value store looks up a value by its key, very fast; often used as a cache 9.3
OLTP and OLAP many small everyday changes / big analytical questions over lots of history 9.5
Replication keeping copies of the data on several machines 9.6, chapter 14
Sharding splitting the data itself across machines 9.6, chapter 14
Connection pool a set of ready-made connections that programs share chapter 12
RPO and RTO how much data you can afford to lose / how long you can afford to be down chapter 12
Data warehouse a database built for analysis, often with fact and dimension tables (a star schema) chapter 13
ETL extract, transform, load: moving data between systems chapter 12, chapter 13
CAP theorem a statement about the trade-offs of a distributed system during a network split chapter 14

Worked example: spotting the terms in a few lines of SQL

This script uses nine of the terms above. Read it first, then see which ones you can name.

import sqlite3

con = sqlite3.connect(":memory:")
con.execute("PRAGMA foreign_keys = ON")
con.execute("CREATE TABLE customers (id INTEGER PRIMARY KEY, name TEXT NOT NULL)")
con.execute("CREATE TABLE orders (id INTEGER PRIMARY KEY, customer_id INTEGER NOT NULL REFERENCES customers(id), total INTEGER CHECK (total >= 0))")
con.execute("CREATE INDEX idx_orders_customer ON orders (customer_id)")
con.execute("CREATE VIEW big_orders AS SELECT * FROM orders WHERE total >= 1000")
con.execute("INSERT INTO customers VALUES (1, 'Rina')")
with con:
    con.execute("INSERT INTO orders VALUES (1, 1, 1500)")
    con.execute("INSERT INTO orders VALUES (2, 1, 300)")
print(con.execute("SELECT * FROM big_orders").fetchall())
try:
    con.execute("INSERT INTO orders VALUES (3, 99, 100)")
except sqlite3.IntegrityError as e:
    print("foreign key:", e)
try:
    con.execute("INSERT INTO orders VALUES (4, 1, -5)")
except sqlite3.IntegrityError as e:
    print("check:", e)
print(con.execute("EXPLAIN QUERY PLAN SELECT * FROM orders WHERE customer_id = 1").fetchall()[0][3])
[(1, 1, 1500)]
foreign key: FOREIGN KEY constraint failed
check: CHECK constraint failed: total >= 0
SEARCH orders USING INDEX idx_orders_customer (customer_id=?)
In the script Term
customers, orders tables (with rows and columns)
id INTEGER PRIMARY KEY primary key
name TEXT NOT NULL, CHECK (total >= 0) constraints
customer_id ... REFERENCES customers(id) foreign key, a one-to-many link
CREATE INDEX and the SEARCH ... USING INDEX line index, shown in the query plan
CREATE VIEW big_orders view
with con: around two inserts one transaction, committed together
FOREIGN KEY constraint failed referential integrity protecting the data

The customer and order data is made up.

Quick check: what is the difference between a primary key and a foreign key?

A primary key identifies the rows of its own table (unique, never NULL). A foreign key lives in another table and holds a primary key's value, to link back to the row it belongs to.

How to use a glossary

  • Look up, then go to the lesson. A two-line definition reminds you; the lesson makes you understand.
  • Group terms into pictures. "Key, constraint, schema" belong to the shape of the data; "transaction, lock, isolation" belong to working at the same time.
  • Say the term in your own words before checking. If you cannot, reread the lesson.

Common mistakes

  • Treating NULL as zero or an empty string. It means "no value or unknown" (lesson 2.3).
  • Mixing up an index and a key. A key is a rule about identity; an index is a speed-up structure. A primary key usually gets an index automatically, but an index alone does not make values unique.
  • Calling every database "SQL". SQL is a language; "relational" is the model; MongoDB and Redis are databases that are not relational.
  • Using "backup" and "replication" as the same thing. A replica copies a mistake (such as a deleted table) almost at once; a backup lets you go back in time (chapters 8 and 12).

Key takeaways

  • Terms fall into groups: basics, structure, relationships, queries, design, transactions, speed, safety and big systems.
  • Keys, constraints and foreign keys protect the shape and meaning of the data.
  • Transactions and isolation protect the data when many things happen at once.
  • Indexes and query plans are about speed; backups and permissions are about safety.
  • Use this page to look terms up, and return to the lesson for the full explanation.

Practice

1. Which term describes "a rule the database enforces itself", and name two examples.

Show answer

A constraint. Examples: NOT NULL, UNIQUE, CHECK, FOREIGN KEY.

2. A shop has customers and products, and each customer can buy many products while each product is bought by many customers. Which structure do you need besides the two tables?

Show answer

A junction table (for example order_items) holding a foreign key to each side (lesson 3.4).

3. What is the difference between normalization and denormalization?

Show answer

Normalization splits data into tables to remove repeated data and the anomalies it causes. Denormalization puts some repeated data back on purpose, usually to make reads faster, and accepts the extra care needed to keep copies in step.

4. Which ACID promise means "all of the changes happen or none of them do"?

Show answer

Atomicity (lesson 6.3).

5. Your database has a daily backup, and a replica that is always up to date. Someone deletes the orders table by mistake. Which one helps you recover, and why?

Show answer

The backup. The replica copies the deletion almost at once, so it has no orders either. The backup is a point in the past that still has them.

6. In your own words, explain the difference between an index and a primary key.

Show answer

A primary key is a rule: it identifies each row and must be unique and not NULL. An index is a helper structure that makes finding rows faster. A primary key is usually backed by an index, but an index on its own does not make values unique or required.