SQL Basics for Beginners: Relational Database Fundamentals
Understand tables, rows, columns, primary keys, and core CRUD statements across modern databases.
Overview & Context
Structured Query Language (SQL) is the universal, standardized language used to manage, store, query, and manipulate data stored in relational databases. First developed by IBM researchers in the 1970s, SQL remains the absolute foundation of data infrastructure across modern banking, e-commerce, cloud software, and analytics platforms.
1. What is an RDBMS?
Relational integrity, ACID compliance, and structured storage
A Relational Database Management System (RDBMS) organizes structured data into two-dimensional tables consisting of horizontal rows (records) and vertical columns (fields).
Relational databases guarantee ACID properties (Atomicity, Consistency, Isolation, Durability), ensuring that financial transactions and critical database operations either succeed completely or roll back without corrupting data.
2. Tables, Columns, and Primary Keys
Every column in a database table has a strictly defined data type (e.g. `INTEGER`, `VARCHAR`, `DECIMAL`, `BOOLEAN`, `TIMESTAMP`).
A Primary Key is a unique identifier assigned to each row in a table. No two rows can share the same primary key value, and a primary key cannot be `NULL`.
3. Creating Tables & Inserting Records
Data Definition Language (DDL) and Data Manipulation Language (DML)
Use `CREATE TABLE` to define your table schema, and `INSERT INTO` to populate it with new rows:
-- Create student directory table
CREATE TABLE students (
student_id SERIAL PRIMARY KEY,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
cgpa DECIMAL(3, 2) DEFAULT 0.00,
enrolled_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Insert sample records
INSERT INTO students (first_name, last_name, email, cgpa)
VALUES
('Sarah', 'Chen', 'sarah.c@university.edu', 8.95),
('Marcus', 'Vance', 'marcus.v@university.edu', 7.40),
('Aisha', 'Patel', 'aisha.p@university.edu', 9.20);4. Executing Basic SELECT Queries
To retrieve information from a database, execute a `SELECT` statement. You can specify exact column names or use the wildcard `*` to fetch all columns:
-- Fetch specific columns
SELECT first_name, email, cgpa
FROM students;
-- Fetch all columns from the table
SELECT * FROM students;- Executing `UPDATE` or `DELETE` statements without a `WHERE` clause. Doing so will overwrite or permanently delete every single row in the entire table!
5. SQL Dialects & Database Engines
While ANSI SQL establishes standard syntax, individual database engines (PostgreSQL, MySQL, SQLite, Microsoft SQL Server, Oracle) include minor syntax variations, specialized date functions, and custom performance extensions.
Summary & Key Takeaways
- 1SQL is the declarative query language for relational databases.
- 2Data is organized in 2D tables of rows and typed columns.
- 3Primary keys uniquely identify records and enforce relational integrity.
- 4Always specify explicit column names rather than `SELECT *` in production code.
Is SQL case-sensitive?
Standard SQL keywords (like SELECT, FROM, WHERE) are case-insensitive, but writing them in UPPERCASE is the universal industry convention. Table and column names may be case-sensitive depending on your database engine configuration and OS filesystem.
What is the difference between SQL and NoSQL?
SQL databases are relational, structured, and use fixed schemas with ACID guarantees. NoSQL databases (like MongoDB, Redis, Cassandra) store unstructured or semi-structured data (JSON documents, key-value pairs) and prioritize horizontal scaling flexibility over relational joins.
Recommended Practical Tools
Next Recommended Reads
Learn how to filter and sort database records with precision. Explore comparison operators, AND/OR logic, LIKE wildcards, and ORDER BY clauses.
Master SQL table joins with practical visual analogies. Learn how and when to use INNER JOIN, LEFT OUTER JOIN, and multi-table joins without performance degradation.
Understand the core discipline of data analytics. Explore the 4 types of analysis, the 6-step analytics lifecycle, and the essential tooling ecosystem.