00:00

What is RDBMS

Last updated: 6 min read

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 termEveryday termExample
RelationTablemembers
TupleRow / recordKavya's details
AttributeColumn / fieldname
DomainAllowed values / data typeINT, DATE
DegreeNumber of columns2 in members
CardinalityNumber of rows3 in members

2. DBMS vs RDBMS

PointDBMS (general)RDBMS
StorageAny format: files, trees, documentsTables of rows and columns
RelationshipsNot necessarily supportedThrough primary and foreign keys
Integrity rulesLimitedConstraints: PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, NOT NULL
Query languageVariesSQL
TransactionsMay be missingACID transactions
ExamplesFile systems, XML stores, early hierarchical systemsMySQL, 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).
Tables linked by keys in a library databaseThree tables. members has member_id. books has book_id. loans links them: each loan row holds a member_id and a book_id, so one member can borrow many books and one book can be borrowed many times.membersmember_idname1Kavya2Aman3Saraloansloan_idmember_idbook_iddue10111203-1010211503-1210331203-15booksbook_idtitle12Dune15Emma18Ulysses1 → manymany ← 1Foreign keys point to theprimary keys of other tablesPK: member_idPK: book_idloans is a bridge table: it turns members ⇄ books (many-to-many) into two one-to-many links.
Figure 1: in an RDBMS, tables are related through keys. The loans table connects members and books.

4. Building the Library Database

Here are the three tables from Figure 1 in MySQL, with their keys:

library.sql
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?":

query.sql
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

nametitledue_date
KavyaDune2026-03-10
KavyaEmma2026-03-12
SaraDune2026-03-15

5. Types of Relationships

RelationshipMeaningLibrary exampleHow it is built
One-to-oneOne row matches at most one rowA member and their library cardFK with a UNIQUE constraint, or share the PK
One-to-manyOne row matches many rowsOne member has many loansFK on the "many" side (loans.member_id)
Many-to-manyMany rows match many rowsMembers and booksA 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.

query.sql
INSERT INTO members VALUES (1, 'Rahul', 'rahul@example.com');
Output
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:

query.sql
INSERT INTO loans VALUES (104, 9, 18, '2026-03-20');
Output
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:

query.sql
DELETE FROM members WHERE member_id = 1;
Output
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:

query.sql
UPDATE books SET copies = -1 WHERE book_id = 18;
Output
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 formSimple ruleLibrary example
1NFEach cell holds one value; no repeating groupsDon't store 'Dune, Emma' in one cell
2NF1NF, and every column depends on the whole keyBook title belongs in books, not in a table keyed by (member, book)
3NF2NF, and no column depends on another non-key columnDon't store the member's email in loans; it depends on the member
Splitting data into 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:

lend-book.sql
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_idtitlecopies
18Ulysses1

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

AdvantagesLimitations
Clear, well-understood structureSchema changes on very large tables need planning
Powerful queries with SQL and joinsScaling writes across many servers is harder than in some NoSQL systems
Strong integrity rules and ACID transactionsDeeply nested or highly variable data can be awkward (JSON columns help)
Mature tools, skills and communityVery complex joins on huge data can be slow without good indexes

10. Practice Exercises

Exercise 1: Which members have no loans?
solution.sql
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.
solution.sql
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

titletimes_borrowed
Dune2
Emma1
Ulysses1

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.