Database
Introduction to SQL
Database
SQL Basics
Creating a Database
Using a Database
Creating a Table
Common Data Types
Inserting Data
Selecting Data
WHERE Clause
Comparison Operators
AND, OR, and NOT
ORDER BY Clause
LIMIT Clause
DISTINCT
LIKE Operator
IN, BETWEEN, and IS NULL
Updating Data
Deleting Data
ALTER TABLE
DROP TABLE
PRIMARY KEY and NOT NULL
FOREIGN KEY and Relationships
Aggregate Functions
GROUP BY Clause
HAVING Clause
JOIN Basics
INNER JOIN
LEFT JOIN
Aliases
Subqueries
Indexes
User Permissions and Security
Common Mistakes Beginners Make
Practice Ideas
Database
Database, Table, Row, and Column
Definition: At its simplest level, a database is an organized system for storing information. Tables reside inside the database and hold that information in a structured grid of rows and columns.
Why: Beginner SQL lessons always start here because these four terms form the foundation of every command you will ever write. You cannot manage data until you understand the structure it lives in.
Core Concepts
| Term | Easy Meaning |
|---|---|
| Database | The container or "file cabinet" that holds a collection of related data. |
| Table | A structured set of data within the database, arranged in rows and columns (like a single sheet in a spreadsheet). |
| Row | A single, complete record in a table (e.g., all information about one specific student). |
| Column | A single field or attribute in a table (e.g., just the "Email" or "Phone Number" category). |
Example Table: students
In the example below, the entire grid is a Table. Each horizontal entry is a Row, and each vertical category is a Column.
| StudentID (Column) | Name (Column) | Grade (Column) |
|---|---|---|
| 101 | Ravi | A |
| ↑ This entire line is a Row (Record) ↑ | ||
| 102 | Anu | B |
Key Notes
- Unique Identifiers: In a professional database, every row usually has a "Primary Key" (like
StudentID) to ensure that no two records are exactly the same. - Data Types: Each column is assigned a specific data type (e.g., the "Name" column only accepts text, while the "Grade" column might only accept a single character).
- Relationships: Tables don't just sit alone; they are often "related" to each other. For example, a
studentstable might be linked to acoursestable.