View Categories

Database Basics

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 #

TypeDescriptionExample
Relational DatabaseData stored in tables (rows & columns)MySQL, PostgreSQL
NoSQL DatabaseFlexible structure (JSON, key-value)MongoDB
Cloud DatabaseHosted onlineFirebase, AWS RDS

Basic Database Concepts #

Table #

  • Data is stored in tables
  • Example: Students table
IDNameAge
1Alex20
2John22

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) #

OperationSQL CommandPurpose
CreateCREATECreate database/table
ReadSELECTRetrieve data
UpdateUPDATEModify data
DeleteDELETERemove 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 #

FunctionPurpose
COUNT()Count rows
SUM()Total
AVG()Average
MAX()Maximum
MIN()Minimum

Example:

SELECT AVG(Age) FROM Students;

Simple Workflow #

  1. Create database
  2. Create tables
  3. Insert data
  4. Query data using SQL
  5. Update/Delete when needed
Database Basics
💬
AIRA (AI Research Assistant) Neural Learning Interface • Drag & Resize Enabled
×