SQL Fundamentals
Introduction to SQL
What is SQL?
Structured Query Language, or SQL, is the standard language for communicating with databases. Think of it as a universal translator for data. Just as you'd use English to ask a librarian for a specific book, you use SQL to ask a database for specific information.
SQL (Structured Query Language) is a language used for managing relational databases.
Its main job is to manage data stored in a relational database. This includes tasks like adding new information, updating what's already there, retrieving data to answer questions, and deleting information that's no longer needed. Almost every application that deals with data, from your banking app to your social media feed, uses a database that likely speaks SQL.
Where Did SQL Come From?
SQL has been around for a while. It was developed at IBM in the early 1970s by Donald D. Chamberlin and Raymond F. Boyce. Their work was based on the relational model for databases, a groundbreaking idea proposed by Edgar F. Codd.
The goal was to create a simple, English-like language that anyone could use to access data, without needing to be a computer scientist. Over the years, it was standardized by organizations like ANSI and ISO, which is why it's so widely used today. While different database systems might have their own minor variations, or "dialects," the core SQL language is the same everywhere.
Learning standard SQL means you can work with many different database systems, like MySQL, PostgreSQL, and SQL Server.
Organizing Data with Tables
SQL works with relational databases. These databases organize information into tables, which are a lot like spreadsheets. Each table stores data about a specific type of thing, like 'Customers' or 'Products'.
A table is made up of columns and rows.
Column
noun
A vertical field in a table that contains a specific type of information for every record, like a 'Name' or 'Price'.
Row
noun
A horizontal record in a table that represents a single item, like one specific customer or one particular product.
Tables can be linked to each other. For example, a 'Customers' table could be linked to an 'Orders' table to show which customer placed which order. This system of related tables is what makes a relational database so powerful.
SQL's Basic Commands
SQL commands, often called statements, are like instructions you give to the database. They are typically written in a straightforward, declarative way: you tell the database what you want, not how to get it. Most statements start with a command word like SELECT, INSERT, or CREATE and end with a semicolon (;).
These commands can be grouped into a few main categories based on what they do.
| Category | Purpose | Common Commands |
|---|---|---|
| Data Query Language (DQL) | Used to retrieve data. | SELECT |
| Data Definition Language (DDL) | Defines or modifies the database structure. | CREATE, ALTER, DROP |
| Data Manipulation Language (DML) | Used to add, update, or remove data. | INSERT, UPDATE, DELETE |
| Data Control Language (DCL) | Manages user permissions and access. | GRANT, REVOKE |
You don't need to memorize all of these at once. The most common command by far is SELECT, which is used to ask the database questions and get information back. As you begin your journey with SQL, you'll start by mastering how to retrieve data before moving on to changing it.
Time to check what you've learned so far.
What is the primary purpose of Structured Query Language (SQL)?
SQL is a declarative language, meaning you specify what data you want, not how the database should get it.
With these basics, you're ready to start exploring how to use SQL to interact with data.