What is it?
A database is an organised collection of structured data stored in tables. SQL (Structured Query Language) is the standard language used to create, read, update, and delete that data.
Why does it matter?
Every web application stores its data in a database. SQL is the universal language for interacting with that data, and it is one of the most in-demand developer skills in the industry.
Beginner introduction to databases, tables, rows, columns, primary keys, and basic CRUD.
Real-World Use Cases
- 🛒 E-commerce product catalogue - Store products, orders, users, and inventory in structured tables — query with SELECT to build product pages.
- 📝 Blog or CMS - Posts, authors, and categories each live in their own table. SQL JOINs bring them together when displaying an article.
- 📊 Analytics dashboard - A visits table records every page view. SQL aggregates (COUNT, SUM, AVG) turn raw rows into meaningful metrics.
- 🏦 Banking application - Account balances, transactions, and customers all live in relational tables with strict integrity enforced by SQL constraints.
Creating Your First Table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
age INT,
email VARCHAR(150) UNIQUE NOT NULL
);
-- AUTO_INCREMENT -- numbers rows automatically: 1, 2, 3...
-- PRIMARY KEY -- uniquely identifies each row
-- NOT NULL -- this field is required, cannot be empty
-- UNIQUE -- no two rows can share the same email
Basic CRUD -- The 4 Core Operations
-- CREATE: insert a new row
INSERT INTO users (name, age, email)
VALUES ('Rahul', 25, 'rahul@example.com');
-- READ: fetch rows
SELECT * FROM users;
SELECT name, email FROM users;
-- UPDATE: change data
UPDATE users SET age = 26 WHERE id = 1;
-- DELETE: remove a row
DELETE FROM users WHERE id = 3;
-- WARNING: always include WHERE! Without it, ALL rows are affected.
Q: What is a Primary Key?
A primary key uniquely identifies each row. No two rows can share the same value and it cannot be NULL. The id INT AUTO_INCREMENT PRIMARY KEY pattern is the most common choice.
Comments (0)
No comments yet. Be the first!
Leave a Comment