What is a Database? #
A database is an organized collection of data that can be easily accessed, managed, and updated.
👉 Think of it like a digital storage system (similar to an Excel sheet, but more powerful).
Example #
- Student records
- Bank accounts
- E-commerce products
Why Do We Use Databases? #
- Store large amounts of data efficiently
- Retrieve data quickly
- Ensure data consistency
- Allow multiple users to access data
Types of Databases #
| Type | Description | Example |
|---|---|---|
| Relational Database | Data stored in tables (rows & columns) | MySQL, PostgreSQL |
| NoSQL Database | Flexible structure (JSON, key-value) | MongoDB |
| Cloud Database | Hosted online | Firebase, AWS RDS |
Basic Database Concepts #
Table #
- Data is stored in tables
- Example:
Studentstable
| ID | Name | Age |
|---|---|---|
| 1 | Alex | 20 |
| 2 | John | 22 |
Row (Record) #
- A single entry in a table
👉 Example:1, Alex, 20
Column (Field) #
- A category of data
👉 Example: Name, Age
Primary Key #
- Unique identifier for each row
👉 Example:ID
Database Management System (DBMS) #
Software used to manage databases
Examples:
- MySQL
- PostgreSQL
- SQLite
SQL Basics (Conceptual) #
What is SQL? #
SQL (Structured Query Language) is used to communicate with databases.
👉 It allows you to:
- Create data
- Read data
- Update data
- Delete data
SQL Core Commands (CRUD) #
| Operation | SQL Command | Purpose |
|---|---|---|
| Create | CREATE | Create database/table |
| Read | SELECT | Retrieve data |
| Update | UPDATE | Modify data |
| Delete | DELETE | Remove data |
SQL Concepts with Examples #
Create Table #
CREATE TABLE Students (
ID INT PRIMARY KEY,
Name VARCHAR(50),
Age INT
);👉 Creates a table named Students
Insert Data
INSERT INTO Students (ID, Name, Age) VALUES (1, 'Alex', 20);
👉 Adds a new row
Select Data
SELECT * FROM Students;
👉 Retrieves all data
SELECT Name FROM Students;
👉 Retrieves specific column
Filter Data (WHERE)
SELECT * FROM Students WHERE Age > 20;
👉 Shows students older than 20
Update Data
UPDATE Students SET Age = 21 WHERE ID = 1;
👉 Updates specific record
Delete Data
DELETE FROM Students WHERE ID = 1;
👉 Removes a row
Important SQL Concepts #
Constraints #
Rules applied to data:
- PRIMARY KEY → Unique
- NOT NULL → Cannot be empty
- UNIQUE → No duplicates
Joins (Conceptual) #
Used to combine multiple tables
👉 Example:
- Students table
- Courses table
Join them using a common column
Aggregation Functions #
| Function | Purpose |
|---|---|
COUNT() | Count rows |
SUM() | Total |
AVG() | Average |
MAX() | Maximum |
MIN() | Minimum |
Example:
SELECT AVG(Age) FROM Students;
Simple Workflow #
- Create database
- Create tables
- Insert data
- Query data using SQL
- Update/Delete when needed

