📡 You're offline — showing cached content
New version available!
Quick Access
SQL Beginner

SQL Basics: What is a Database and How Do Tables Work?

Beginner introduction to databases, tables, rows, columns, primary keys, and basic CRUD.

EzyCoders Admin April 14, 2026 6 min read 0 views
SQL Basics: What is a Database and How Do Tables Work?
Share: Twitter LinkedIn WhatsApp

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.

EzyCoders Admin
Written by
EzyCoders Admin

Team Lead and Full-Stack Developer with experience in PHP, JavaScript, SQL, DSA, and System Design. Passionate about software engineering, scalable web technologies, and helping developers prepare for coding interviews and tech careers through practical tutorials and professional guidance.

Comments (0)

No comments yet. Be the first!

Leave a Comment