What is RDBMS
An RDBMS (Relational Database Management System) is software that stores data in related tables and lets you work with it using SQL. MySQL is one of the world's most popular RDBMS products, alongside PostgreSQL, Oracle Database, Microsoft SQL Server and MariaDB.
In this tutorial you will learn the building blocks of an RDBMS: tables, keys, relationships, integrity rules, normalization and ACID transactions, each with a small MySQL example based on a library.
1. What is an RDBMS?
The relational model was described by E. F. Codd at IBM in 1970. Its key idea: store everything in relations (tables), and link tables through matching values rather than physical pointers. An RDBMS is a DBMS that implements this model.
| Relational term | Everyday term | Example |
|---|---|---|
| Relation | Table | members |
| Tuple | Row / record | Kavya's details |
| Attribute | Column / field | name |
| Domain | Allowed values / data type | INT, DATE |
| Degree | Number of columns | 2 in members |
| Cardinality | Number of rows | 3 in members |
2. DBMS vs RDBMS
| Point | DBMS (general) | RDBMS |
|---|---|---|
| Storage | Any format: files, trees, documents | Tables of rows and columns |
| Relationships | Not necessarily supported | Through primary and foreign keys |
| Integrity rules | Limited | Constraints: PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, NOT NULL |
| Query language | Varies | SQL |
| Transactions | May be missing | ACID transactions |
| Examples | File systems, XML stores, early hierarchical systems | MySQL, PostgreSQL, Oracle, SQL Server |
3. Keys: How Rows Are Identified and Linked
- Primary key (PK): a column (or set of columns) that uniquely identifies each row and is never NULL, such as
member_id. - Candidate key: any column that could be the primary key, such as a unique
email. - Foreign key (FK): a column that refers to the primary key of another table, such as
loans.member_id. - Composite key: a key made of two or more columns together.
- Surrogate vs natural key: an invented number (
AUTO_INCREMENT) versus a real-world value (ISBN).
loans table connects members and books.4. Building the Library Database
Here are the three tables from Figure 1 in MySQL, with their keys:
CREATE DATABASE city_library;
USE city_library;
CREATE TABLE members (
member_id INT PRIMARY KEY,
name VARCHAR(40) NOT NULL,
email VARCHAR(80) UNIQUE
);
CREATE TABLE books (
book_id INT PRIMARY KEY,
title VARCHAR(80) NOT NULL,
copies INT CHECK (copies >= 0)
);
CREATE TABLE loans (
loan_id INT PRIMARY KEY,
member_id INT NOT NULL,
book_id INT NOT NULL,
due_date DATE,
FOREIGN KEY (member_id) REFERENCES members(member_id),
FOREIGN KEY (book_id) REFERENCES books(book_id)
);
INSERT INTO members VALUES (1,'Kavya','kavya@example.com'),(2,'Aman','aman@example.com'),(3,'Sara',NULL);
INSERT INTO books VALUES (12,'Dune',3),(15,'Emma',1),(18,'Ulysses',2);
INSERT INTO loans VALUES (101,1,12,'2026-03-10'),(102,1,15,'2026-03-12'),(103,3,12,'2026-03-15');
Because tables are linked by keys, one JOIN query can answer "who borrowed what?":
SELECT m.name, b.title, l.due_date
FROM loans l
JOIN members m ON m.member_id = l.member_id
JOIN books b ON b.book_id = l.book_id
ORDER BY l.due_date;
Result: 3 rows
| name | title | due_date |
|---|---|---|
| Kavya | Dune | 2026-03-10 |
| Kavya | Emma | 2026-03-12 |
| Sara | Dune | 2026-03-15 |
5. Types of Relationships
| Relationship | Meaning | Library example | How it is built |
|---|---|---|---|
| One-to-one | One row matches at most one row | A member and their library card | FK with a UNIQUE constraint, or share the PK |
| One-to-many | One row matches many rows | One member has many loans | FK on the "many" side (loans.member_id) |
| Many-to-many | Many rows match many rows | Members and books | A bridge table (loans) with two FKs |
6. Integrity Rules the RDBMS Enforces
An RDBMS refuses data that breaks the rules. This is called data integrity.
Entity integrity: the primary key must be unique and not NULL.
INSERT INTO members VALUES (1, 'Rahul', 'rahul@example.com');
ERROR 1062 (23000): Duplicate entry '1' for key 'members.PRIMARY'
Referential integrity: a foreign key must point to a row that exists. There is no member 9:
INSERT INTO loans VALUES (104, 9, 18, '2026-03-20');
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`city_library`.`loans`, CONSTRAINT `loans_ibfk_1` FOREIGN KEY (`member_id`) REFERENCES `members` (`member_id`))
And you can't delete a member who still has loans, because that would leave loans pointing at nobody:
DELETE FROM members WHERE member_id = 1;
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`city_library`.`loans`, CONSTRAINT `loans_ibfk_1` FOREIGN KEY (`member_id`) REFERENCES `members` (`member_id`))
Domain integrity: values must fit the column's type and checks:
UPDATE books SET copies = -1 WHERE book_id = 18;
ERROR 3819 (HY000): Check constraint 'books_chk_1' is violated.
7. Normalization in Brief
Normalization is the process of organising tables so that each fact is stored once. Imagine one big table where every loan repeats the member's name and email. If Kavya changes her email, you must update many rows, and missing one leaves the data inconsistent.
| Normal form | Simple rule | Library example |
|---|---|---|
| 1NF | Each cell holds one value; no repeating groups | Don't store 'Dune, Emma' in one cell |
| 2NF | 1NF, and every column depends on the whole key | Book title belongs in books, not in a table keyed by (member, book) |
| 3NF | 2NF, and no column depends on another non-key column | Don't store the member's email in loans; it depends on the member |
members, books and loans is exactly what normalization recommends. Joins put it back together when you need it.8. ACID Transactions
An RDBMS groups changes into transactions with four guarantees: Atomicity, Consistency, Isolation and Durability. Lending a book needs two changes: add a loan and reduce the available copies. They must happen together:
START TRANSACTION;
INSERT INTO loans VALUES (104, 2, 18, '2026-03-22');
UPDATE books SET copies = copies - 1 WHERE book_id = 18;
COMMIT;
SELECT book_id, title, copies FROM books WHERE book_id = 18;
Result: 1 row
| book_id | title | copies |
|---|---|---|
| 18 | Ulysses | 1 |
If anything fails before COMMIT, a ROLLBACK undoes both changes, so you never get a loan without the stock going down. See MySQL Transaction for details.
9. Advantages and Limitations
| Advantages | Limitations |
|---|---|
| Clear, well-understood structure | Schema changes on very large tables need planning |
| Powerful queries with SQL and joins | Scaling writes across many servers is harder than in some NoSQL systems |
| Strong integrity rules and ACID transactions | Deeply nested or highly variable data can be awkward (JSON columns help) |
| Mature tools, skills and community | Very complex joins on huge data can be slow without good indexes |
10. Practice Exercises
Exercise 1: Which members have no loans?
SELECT m.name
FROM members m
LEFT JOIN loans l ON l.member_id = m.member_id
WHERE l.loan_id IS NULL;
Result: Empty set (0 rows)
| name |
|---|
| No rows |
Exercise 2: How many times has each book been borrowed? Include books never borrowed.
SELECT b.title, COUNT(l.loan_id) AS times_borrowed
FROM books b
LEFT JOIN loans l ON l.book_id = b.book_id
GROUP BY b.book_id, b.title
ORDER BY times_borrowed DESC, b.title;
Result: 3 rows
| title | times_borrowed |
|---|---|
| Dune | 2 |
| Emma | 1 |
| Ulysses | 1 |
11. Summary
- An RDBMS stores data in related tables and is queried with SQL. MySQL is a popular example.
- Primary keys identify rows; foreign keys link tables.
- Relationships can be one-to-one, one-to-many or many-to-many (through a bridge table).
- The RDBMS enforces entity, referential and domain integrity.
- Normalization stores each fact once; joins combine the tables again.
- ACID transactions keep related changes all-or-nothing.