SQL Study Material

Databases & RDBMS

What is a Database?

A database is an organized collection of data stored electronically, so that it can be searched, updated and shared safely by many users at the same time.

A Database Management System (DBMS) is the software that stores the data and answers requests for it, for example MySQL or PostgreSQL.

RDBMS

RDBMS stands for Relational Database Management System. In a relational database, data is stored in tables, and tables are linked to each other through shared values (keys).

RDBMS is the basis for SQL and for all modern database systems such as MySQL, SQL Server, Oracle, PostgreSQL and SQLite.

Tables, Rows and Columns

A table is a collection of related data, made of columns and rows. This is the Customers table used throughout this tutorial:

CustomerIDCustomerNameContactNameCityCountry
1Aarav TradersAarav ShahMumbaiIndia
2Blue Harbor FoodsEmma ClarkLondonUK
3Cedar & CoLiam BrownTorontoCanada
4Delta MartPriya NairBengaluruIndia
5Evergreen GrocersNoah WilsonNew YorkUSA
6Fjord SuppliesIngrid OlsenOsloNorway
7Golden SpoonMei ChenNULLSingapore
8Harbor LightsOlivia MartinLondonUK
  • Column (field): one piece of information for every record, e.g. City.
  • Row (record): one complete entry, e.g. the customer "Delta Mart".
  • Primary key: a column whose value uniquely identifies each row, here CustomerID.

Why Relational?

Instead of repeating customer details on every order, the Orders table stores only the CustomerID. The two tables are related through that column, so a customer's address is stored once and every order points to it.

  • No duplication: each fact is stored in one place.
  • Integrity: constraints stop invalid data, such as an order for a customer that does not exist.
  • Flexibility: joins let you combine tables in any way at query time.