Interview's MateSQL Learning
Interview's Mate

SQL Learning

Foundations → production SQL

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
SQL topics
Lesson 1/ 160
01. SQL Foundations & Relational Concepts

What is a Database? (DBMS vs RDBMS)

Clarify databases, DBMS vs RDBMS, and why relational systems dominate transactional apps.

BeginnerDBMS · RDBMS · Persistence3 quiz questions
Practice SQL
In plain wordsDiagramExamples & theoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

A database is where an app keeps its data. A DBMS is the program that looks after it. An RDBMS keeps the data in tables that point to each other.

Think of it like…

A DBMS is a librarian who looks after a collection of documents for you. An RDBMS is a librarian who insists everything is filed on standard index cards in labelled drawers with cross-references, so any question can be answered by combining drawers, and nothing gets filed half-finished.

Where you’ve seen it

An online shop keeps customers, orders and payments in PostgreSQL (an RDBMS) because money must never be half-recorded, and caches product pages in Redis (a key-value DBMS) because it needs very fast lookups by key and can rebuild the cache if it's lost.

Words you’ll hear

DBMS
Software that stores, retrieves and manages data: relational or not.
RDBMS
A DBMS using tables, keys, SQL, constraints and transactions.
Schema
The defined structure of the data: tables, columns, types and relationships.
NoSQL
Non-relational DBMSs: document, key-value, wide-column and graph stores.

Visual diagram

Loading interactive diagram

Theory & example queries

DBMS vs RDBMS

Any DBMS stores data persistently and handles concurrent access. An RDBMS adds the relational model: data in tables with a fixed schema, relationships expressed through primary and foreign keys, and a declarative query language (SQL) that can combine tables with joins.

It also enforces integrity with constraints (NOT NULL, UNIQUE, FOREIGN KEY, CHECK) and groups changes into ACID transactions. That's why relational databases dominate systems where correctness matters: banking, orders, bookings and inventory.

Relational data in practiceQuery example
1Input dataStart from the source rows or state that the statement sees.
customers
3 rows
customers sample rows
idnameemailcity
1Mayamaya@example.comPune
2Raviravi@example.comDelhi
3Noornoor@example.comMumbai
orders
3 rows
orders sample rows
idcustomer_idstatusamountcoupon_code
1011paid249NULL
1022paid120WELCOME10
1031shipped89.5NULL
2QuerySwitch dialects, then select a line or execution step to trace it.
query.sql
1SELECT2  c.name,3  SUM(o.amount)4FROM5  customers c6  JOIN orders o ON o.customer_id = c.id7GROUP BY8  c.name;
Logical execution order
Native / baseline

PostgreSQL is the lesson baseline unless noted otherwise.

Line 1 · Project and calculate

Calculate the selected expressions and return the requested output columns.

1/8
3OutputInspect the representative rows, affected-row count, plan, or command status.
Customer revenue totals3 sample rows
Customer revenue totals
namesum
Asha Rao4250
Kabir Shah3120
Mei Chen2890

Note: Illustrative customer and order rows; SUM reflects the joined orders for each customer.

4ExplanationConnect the result back to the SQL rule and the edge case it demonstrates.

One question answered across two related tables.

Key takeaway: Every RDBMS is a DBMS; RDBMSs add tables, keys, SQL, constraints and transactions.

Relational or NoSQL?

Choose a relational database by default when data has clear relationships, needs to stay consistent, and will be queried in ways you can't fully predict. Modern RDBMSs also handle JSON columns and scale further than most applications need.

Non-relational stores fit specific access patterns: key-value stores for caching and sessions, document stores for self-contained records with varying fields, wide-column stores for enormous write-heavy datasets accessed by key, and graph databases for relationship-heavy queries. The lines have blurred, since MongoDB supports multi-document transactions and PostgreSQL stores JSON, so decide by access pattern rather than by label.

Picking by access pattern

Orders, payments and stock → PostgreSQL. Session tokens and rate-limit counters → Redis. Billions of sensor readings looked up by device and time → a wide-column or time-series store.

Key takeaway: Default to relational; use other stores for specific, well-understood access patterns.
Interactive walkthrough

How it works, step by step

Follow one practical SQL workflow from start to finish. Select any step or play through the flow.

Progress1/4
Step 1Design

Model the data

Identify the entities (customers, orders, products) and how they relate. Clear relationships point towards a relational design.

Focus at this step

customer 1 - many orders

What to watch at this step
Relationships
→ relational
Tip: use ← → to move between steps

When to use it & trade-offs

What it is

A database is an organised, persistent collection of data. A DBMS (database management system) is the software that stores it and lets you query and change it safely: PostgreSQL, MySQL, MongoDB and Redis are all DBMSs. An RDBMS is a DBMS built on the relational model: data lives in tables with rows and columns, linked by keys, queried with SQL, and protected by constraints and transactions.

Why it matters: "What's the difference between a DBMS and an RDBMS?" and "SQL or NoSQL?" are among the most common opening questions in fresher and backend interviews. More practically, the choice decides how your data stays consistent, how you query it and how it scales.

When to reach for it

  • Relational databases for transactional business data
  • Key-value stores for caches and sessions alongside a relational database
  • Document stores when records are self-contained and vary a lot

When to avoid or be careful

  • Choosing NoSQL only to avoid designing a schema
  • Storing money and orders in a cache-style store without transactions
  • Treating "SQL vs NoSQL" as a question with one right answer for everything

Relational vs document vs key-value

Relational (PostgreSQL, MySQL)
Best for: Structured, related data that must stay consistent

Strengths: Joins, constraints, ACID transactions, flexible queries.

Watch out: Schema changes need migrations; scaling writes across many servers takes more work.

Document (MongoDB)
Best for: Self-contained records with varying fields

Strengths: Flexible schema; a whole record read in one go.

Watch out: Cross-document queries and integrity are harder.

Key-value (Redis, DynamoDB)
Best for: Very fast lookups by key: caches, sessions, counters

Strengths: Extremely fast and simple to scale.

Watch out: Little or no querying beyond the key.

Interview signals & numbers to know

When this topic comes up

  • “What is a DBMS?”
  • “DBMS vs RDBMS”
  • “SQL or NoSQL for this system?”
  • System design storage choices
  • Fresher interview basics

Benchmarks & rules of thumb

4 -
main NoSQL families: document, key-value, wide-column, graph
ACID -
transaction guarantees of an RDBMS
1970 -
year Codd published the relational model

Common mistakes & follow-ups

Common interview mistakes

  • Saying an RDBMS is just "a database with tables" without mentioning keys, constraints and transactions.
  • Claiming NoSQL databases can never do transactions or joins; many now offer both in limited forms.
  • Picking a database by popularity instead of by how the data will be read and written.

Likely interviewer follow-ups

  • Why do banks use relational databases?
  • When would you choose MongoDB over PostgreSQL?
  • What does a DBMS do that storing data in files doesn't?
Interview tip: Answer DBMS vs RDBMS in one line, then add what the relational model gives you (keys, joins, constraints, transactions) and one example of when you'd use something else. That turns a definition into a design answer.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply What is a Database? (DBMS vs RDBMS) with hands-on SQL practice and interview Q&A.

Open SQL Practice →SQL interview Q&A
Next topic
Relational Model: Tables, Rows, Columns & Schemas