Database Fundamentals
Before writing SQL, it helps to picture how a relational database stores information. The ideas here apply to SQL Server, MySQL, PostgreSQL and every other relational database.
On this page · 5 min · Beginner
On this page
- In simple words
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Beginner
- Updated
- Oct 27, 2026
Related tutorials
In simple words#
A database is a well-organised school office. Each register (table) holds one kind of record — students, classes, fees — in rows and columns, and registers refer to each other by roll number (keys).
- Table
- Rows (records) and columns (fields) about one thing.
- Primary key
- A unique ID for each row.
- RDBMS
- Relational database system, e.g. SQL Server.
Learning objectives#
- Explain what a database and a DBMS are
- Describe tables, rows and columns
- Understand primary and foreign keys
- Know what SQL is used for
Explanation#
A database is an organised collection of data. A database management system (DBMS) such as SQL Server is the software that stores it safely, lets many users read and change it at once, and recovers it after crashes.
In a relational database, data lives in tables. Each table describes one kind of thing — customers, products, orders. A column is one attribute (Name, City); a row is one record (one customer).
Every table should have a primary key: a column whose value uniquely identifies each row. A foreign key is a column that points to a primary key in another table, which is how tables are related — an order “belongs to” a customer.
SQL (Structured Query Language) is the language you use to create tables, insert and change data, and ask questions (queries). SQL Server’s dialect is called T-SQL.
Code example: Asking a database a question#
-- Which customers live in Pune?
SELECT CustomerId, Name, City
FROM Customers
WHERE City = 'Pune';
CustomerId Name City 1 Asha Pune 3 Meera Pune
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- SELECT lists the columns you want back.
- FROM names the table to read.
- WHERE keeps only the rows that match the condition.
- The result is itself a small table — a result set.
Real-world use case#
An online shop keeps customers, products and orders in separate tables. When you view “My orders”, the website runs a query that joins those tables to build the page.
Common mistakes#
Repeating a customer’s address on every order wastes space and causes inconsistencies when the address changes. Split data into related tables.
Without a unique key, duplicate rows creep in and individual rows are hard to update or reference.
Best practices#
- Give every table a primary key
- Name tables after the thing they store (Customers, Orders)
- Store each fact once and relate tables with keys
- Use the right data type for each column
Remember this#
Database → tables → rows (records) and columns (fields).
Primary key = unique roll number of each row.
Relational = tables linked by keys.
Practice exercise#
Your task: Write a query that returns the Name of every customer who lives in Delhi.
Show solution
SELECT Name FROM Customers WHERE City = 'Delhi';
Mini quiz#
In a table, what is a row?
Want more? Practise all SQL Server MCQs · SQL Server interview questions
My notes#
Saved in this browser.