Free demoJob-oriented courses at Debugshala, Old Palasia, Indore. Freshers, non-IT and year-gap welcome.Book a free demo +91-8982385539

What is SQL? Databases, Tables and RDBMS Explained Simply

Lesson 1 of 29 · 10 min · Updated 13 Nov 2026

What is SQL? Learn how relational databases store tables, what an RDBMS does, and run your first real SQL query in Python with zero setup needed.

Picture a small grocery chain in Indore with four branches: Vijay Nagar, Palasia, Rajwada and Bhawarkuan. Every evening each branch manager writes the day's bills into a register, and once a week the owner calls each of them to ask, "How much did we sell, and who were our best customers?"

The calls take an hour, two managers spell the same customer's name differently, and the owner never gets the same answer twice.

Now imagine all four registers typed into one shared system, with one page for customers, one for products and one for bills. The owner types a single question and gets the answer in a second. That shared system is a database, each page is a table, and the precise way the owner types the question is SQL.

SQL (Structured Query Language) is a standard language for defining, changing and querying data stored in relational databases.

Throughout this series you will work with that chain. We will call it Malwa Mart (a made-up business), with four tables: stores, customers, products and orders. Every article builds on the same tables, so the examples feel like one growing project.

What is SQL used for?

SQL is used wherever an organisation needs to keep records it can trust and search quickly. Banks store accounts in it, food delivery apps store orders in it, and hospitals store appointments in it.

A data analyst uses SQL mainly to read data: "Which store sold most in March?" or "How many customers ordered only once?" The database does the heavy work and returns a small, clean result.

SQL is declarative. You describe the result you want, not the steps to get it. You never tell the database to "open page 3 and loop through each line". You say "give me orders above 500 rupees", and the database decides how to find them.

What is a database, a DBMS and an RDBMS?

A database is an organised collection of data stored so a computer can find and update it reliably. A notebook of bills is data; a database is that data arranged so a program can search it.

A DBMS (database management system) is the software that manages a database: storage, many users at once, permissions and crash recovery.

An RDBMS (relational database management system) is a DBMS that stores data as related tables. "Relational" comes from the mathematical idea of a relation, which in practice means a table. Almost every SQL database you will meet at work is an RDBMS.

Tables, rows and columns

A table holds one kind of thing. The customers table holds customers; the orders table holds orders. Each row is one record, such as one customer. Each column is one attribute, such as the customer's city, and every value in a column has the same data type.

Primary keys and foreign keys

A primary key is a column whose value is unique for every row, such as customer_id. It lets you point at exactly one customer even if two people are both called Ravi Patel.

A foreign key is a column in one table that stores the primary key of another. The orders table stores customer_id instead of copying the customer's name and phone into every bill. That single link is what makes the database relational.

What is SQL: a relational database with customers and orders tables linked by a primary key and foreign key

Each order row points to one customer through customer_id. The name is stored once, in customers, and never repeated.

Quick check

In a relational database, what does a foreign key do?

How does a SQL query run inside an RDBMS?

Several things happen between sending a query and seeing a result. Knowing them helps you read error messages later.

  1. You send the SQL text. It may come from a tool such as DBeaver, a Python script, or a dashboard like Power BI.
  2. The parser checks the grammar. A missing comma or a misspelt keyword fails here with a syntax error.
  3. The planner chooses a route. It decides whether to scan the whole table or use an index, and in what order to combine tables.
  4. The executor reads the storage. It fetches the rows from disk or memory and applies your filters.
  5. The result set comes back. You receive a small table of rows and columns, ready to read or export.
How a SQL query runs: client sends SQL to the RDBMS parser, planner and executor, which return a result set

You only write step one. The RDBMS handles parsing, planning and reading the data for you.

SQL is an ANSI and ISO standard, so the core language is shared. Each product adds extras, called its dialect, and this series points out differences when they matter.

RDBMS Licence Where you will see it
MySQL Open source (owned by Oracle), with paid editions Web apps, many Indian startups, WordPress sites
PostgreSQL Open source Analytics teams, modern SaaS products, data engineering
Microsoft SQL Server Commercial, with a free Express edition Large companies using Microsoft tools and Power BI
Oracle Database Commercial Banks, telecom, government and large enterprises
SQLite Public domain, built into apps Mobile phones, browsers, Python's standard library

SQLite is not a server you connect to; it is a small library that keeps a whole database in one file or in memory. That makes it ideal for learning, and this series uses it for every runnable example.

Types of SQL commands

SQL statements fall into five families. Analysts spend most of their time in the query family, but you will see the others in this series.

Family Purpose Main commands
DDL (Data Definition) Create and change table structure CREATE, ALTER, DROP
DML (Data Manipulation) Add, change and remove rows INSERT, UPDATE, DELETE
DQL (Data Query) Read data SELECT
DCL (Data Control) Give and remove permissions GRANT, REVOKE
TCL (Transaction Control) Save or undo a group of changes COMMIT, ROLLBACK

Quick check

Which of these is a database product, not a language?

Your first SQL query with Python and SQLite

You can run SQL right here. The block below creates an empty database in memory, builds a small customers table, adds four rows and asks a question. If Python is new to you, the getting started guide explains how to run code.

Here is the SQL on its own, so you can read it first.

SQL
CREATE TABLE customers (
    customer_id INTEGER PRIMARY KEY,
    name        TEXT,
    city        TEXT
);

SELECT name, city
FROM customers
WHERE city = 'Indore';

And here it is running inside Python, which is how the rest of this series works.

Python
import sqlite3

con = sqlite3.connect(":memory:")   # a fresh database that lives only in RAM
con.execute("""
    CREATE TABLE customers (
        customer_id INTEGER PRIMARY KEY,
        name        TEXT,
        city        TEXT
    )
""")
con.executemany("INSERT INTO customers VALUES (?, ?, ?)", [
    (1, "Asha Verma", "Indore"), (2, "Ravi Patel", "Indore"),
    (3, "Meera Joshi", "Dewas"), (4, "Pooja Rathore", "Ujjain"),
])

rows = con.execute("SELECT name, city FROM customers WHERE city = 'Indore'").fetchall()
for name, city in rows:
    print(name, "-", city)
print("SQLite version:", sqlite3.sqlite_version)

Two of the four customers live in Indore, so two rows come back as Python tuples.

Asking a question across two tables

The real power appears when you combine tables. This block adds an orders table that stores only customer_id, then asks for each customer's total spending. You will learn every clause used here later in the series; for now, notice how little you have to write.

Python
import sqlite3

con = sqlite3.connect(":memory:")
con.execute("CREATE TABLE customers (customer_id INTEGER PRIMARY KEY, name TEXT, city TEXT)")
con.execute("CREATE TABLE orders (order_id INTEGER PRIMARY KEY, customer_id INTEGER, amount INTEGER)")
con.executemany("INSERT INTO customers VALUES (?, ?, ?)", [
    (1, "Asha Verma", "Indore"), (2, "Ravi Patel", "Indore"), (3, "Meera Joshi", "Dewas"),
])
con.executemany("INSERT INTO orders VALUES (?, ?, ?)", [
    (101, 1, 1040), (102, 2, 330), (103, 1, 275), (104, 3, 180), (110, 1, 465),
])

query = """
SELECT c.name, COUNT(*) AS orders, SUM(o.amount) AS total_spent
FROM orders AS o
JOIN customers AS c ON c.customer_id = o.customer_id
GROUP BY c.name
ORDER BY total_spent DESC
"""
for row in con.execute(query):
    print(row)

Asha placed three orders worth 1,780 rupees in total, so she comes first. The names came from one table and the amounts from another, joined through customer_id.

Common misconceptions about SQL

  • "SQL is a programming language like Python." It is a query language. You describe results; you do not write loops. Many databases add procedural extras, but everyday SQL has no loops.
  • "SQL and MySQL are the same thing." SQL is the language. MySQL is one product that understands it, alongside PostgreSQL, SQL Server and others.
  • "Keywords must be uppercase." SQL keywords are case-insensitive. Writing them in capitals is only a readability habit, and this series follows it.
  • "You need a server to practise." SQLite runs inside Python, so a laptop or even this browser page is enough.

If you want a guided path with a teacher beside you, Debugshala's SQL and analytics training in Indore starts with exactly these foundations at its Old Palasia campus.

Key takeaways

  • SQL is a declarative language for defining, changing and querying relational data.
  • An RDBMS stores data as tables of rows and columns and links them with primary and foreign keys.
  • MySQL, PostgreSQL, SQL Server, Oracle and SQLite all speak SQL with small dialect differences.
  • SQL commands group into DDL, DML, DQL, DCL and TCL.
  • Python's sqlite3 module lets you practise real SQL with no setup. Next, learn which SQL data types each column can hold.
Take the free SQL quiz10 quick questions with explanations. No sign-up needed, and you can come back to this lesson after.

FAQ

Is SQL hard to learn for a non-IT student?

No. SQL is one of the easiest technical skills to start, because a basic query reads almost like an English sentence. Most beginners write useful SELECT queries within a few days. The harder parts, such as joins and window functions, come later and build on the same few ideas.

What is the difference between SQL and MySQL?

SQL is the language, and MySQL is a database product that understands it. PostgreSQL, SQL Server, Oracle and SQLite are other products that use the same language with small differences. Learning standard SQL first means you can switch between these products with very little extra effort.

Do data analysts need to know SQL?

Yes. SQL is the most commonly listed skill in data analyst job descriptions, because company data lives in databases. Analysts use it to pull, filter and summarise data before building reports in Excel or Power BI. The data analyst role guide shows where it fits in daily work.

Which SQL database should I install first?

Start with SQLite through Python, because it needs no installation and behaves like a real database. When you build a portfolio project, install PostgreSQL or MySQL, both free. The official SQLite documentation is a good reference while you practise.

Where can I learn SQL in Indore with classroom support?

Debugshala, an IT training and placement institute at Old Palasia, Indore, offers a Data Analytics course with offline classes in English and Hindi. You can attend a free demo class before paying anything. Between sessions, practise MCQs on the Debugshala Test platform to keep your logic sharp.

From the team behind this site

Go further with the Data Analytics Course at Debugshala

These tutorials are written by Debugshala, a training and placement institute at Old Palasia, Indore. The classroom course adds live mentoring, real projects and interview preparation.

  • Offline classes at Old Palasia, Indore
  • Free demo class before you pay
  • Non-IT, fresher and year-gap friendly
  • Placement assistance

700+ students placed · 200+ hiring partners · 4.9★ Google rating

SQL Data Types: INT, DECIMAL, VARCHAR and DATE Explained