OrgPad logo

SQL Mindmap

Created by Anand Kumar

Ever felt SQL has too many commands and concepts? This mindmap simplifies everything — so you can learn step-by-step and master SQL with confidence.

SQL Mindmap

Unique

NOT NULL

Primary Key (PK)

Foregin Key (FK)

Check

Default

COLUMN

CONSTRAINTS

COLUMN

CONSTRAINTS

DATA TYPE

DEFAULT

ADD

REMOVE

MODIFY

Column(s)

DATABASE

TABLE

VIEW

TABLE

TABLE

DATABASE

TABLE

All Table(*)

SELECT

Retrieves data from one or more tables.

VIEW

ALTER

ALTER is used to modify the structure of an existing database object, such as a table.

DROP

TRUNCATE

DDL

Data to Table

INSERT

Adds new records to a table.

DML

DML Commands (Data Manipulation Language)

ALIAS

Alias is a temporary name given to a table or column in a SQL query.

It improves readability and simplifies complex queries.

AS

For Columns:

SELECT column_name AS alias_name  FROM table_name;

For Table:

SELECT t.column_name  FROM table_name AS t;

Field

UPDATE

Modifies existing records in a table.

GROUP BY COLUMN

Field

DELETE

Removes records from a table.

GROUP BY

SQL

HAVING

Filters grouped results based on aggregate conditions.

GRANT

Gives specific privileges to users on database objects (e.g., tables, views).

DCL

DCL Commands (Data Control Language)

ORDER BY

ORDER BY ASC

Sorts results in ascending order (default).

Example: ORDER BY name ASC

REVOKE

Removes previously granted privileges from users.

TCL

TCL Commands (Transaction Control Language)

ORDER BY DESC

Sorts results in descending order.

Example: ORDER BY salary DESC

INNER JOIN

Returns only matching rows from both tables.

Example: Customers with orders.

COMMIT

Saves all changes made during the current transaction permanently.

JOIN(s)

Joins are used to combine rows from two or more tables based on a related column.

FULL JOIN

Returns all rows when there is a match in either table.

Example: All customers and all orders, matched where possible.

ROLLBACK

Reverts changes made during the current transaction.

SET TRANSACTION

Defines properties for a transaction (e.g., isolation level).

RIGHT JOIN

Returns all rows from the right table, and matching rows from the left table.

Example: All orders, even if no customer info is available.

SAVEPOINT

Sets a point within a transaction to which you can later roll back.

OVER()

WINDOW FUNCTIONS

Window functions perform calculations across a set of table rows related to the current row, without collapsing rows like aggregate functions do.

RANK()

Assigns a rank to each row within a partition, with gaps for ties.

EXISTS

WHERE

LEFT JOIN

Returns all rows from the left table, and matching rows from the right table.

Example: All customers, even those without orders.

FUNCTIONS

A function is a built-in or user-defined operation that performs a specific task and returns a value.

Functions are typically used to manipulate data, perform calculations, or format results within queries.

LAG()

Returns data from the previous row in the partition.

ROW_NUMBER()

Assigns a unique sequential number to rows within a partition.

<, >, < >, <=, >=, =

1. =

2. <> or !=

3. >, <, >=, <=

CROSS JOIN

Returns the Cartesian product of both tables (every combination of rows).

Example: All possible customer-product pairs.

NTILE()

Divides rows into n equal groups and assigns a group number to each row.

DENSE_RANK()

Similar to RANK(), but without gaps in ranking for ties.

SELF JOIN

Joins a table to itself to compare rows within the same table.

Example: Employees and their managers.

CONCAT()

Combines two or more strings into one.

LEAD()

Returns data from the next row in the partition.

IS NULL / IS NOT NULL

Checks for null values.Example: WHERE email IS NOT NULL

SUM()

Calculates the total sum of a numeric column.

AVG()

Returns the average value of a numeric column.

ANY

IN

Checks if a value matches any value in a list.Example: WHERE country IN ('Germany', 'France')

LIKE

Pattern matching using wildcards (%, _).Example: WHERE name LIKE 'A%'

AND, OR, NOT

AND / OR

NOT

ALL

BETWEEN

Checks if a value is within a range.Example: WHERE age BETWEEN 18 AND 30

NOW() / GETDATE()

Returns the current date and time.

MAX()

Finds the largest value in a column.

SUBSTRING()

Extracts part of a string.

UPPER()

Converts text to uppercase.

MIN()

Finds the smallest value in a column.

COUNT()

Returns the number of rows that match a condition.

ISNULL() / IFNULL()

Replaces NULL with a specified value.

ROUND()

Rounds a numeric value to the specified number of decimal places.

LOWER()

Converts text to lowercase.

COALESCE()

Returns the first non-null value from a list.

LENGTH()

Returns the length of a string.