No history yet

Introduction to SQL

What is SQL?

SQL stands for Structured Query Language. At its core, it's the standard language for communicating with databases. Think of a database as a massive, incredibly organized digital filing cabinet. SQL is the language you use to ask that filing cabinet to store, change, or retrieve specific pieces of information.

SQL (Structured Query Language) is a standard programming language designed to manage and manipulate relational databases.

Most of the databases you'll encounter are relational databases. This just means the data isn't thrown in randomly; it's organized into a collection of tables that can be related to one another. Imagine a set of spreadsheets where a customer ID in one sheet can link to that same customer's order history in another. That's the basic idea of a relational database.

The Building Blocks

To understand databases, you need to know their three basic components: tables, columns, and rows. They work together to create a logical structure for the data.

Let's break that down.

  • Table: A table contains data about a single subject, like Users, Products, or Orders. In our example, the whole structure is the Users table.

  • Columns: Columns define the attributes of the subject. They are the vertical categories in the table. For the Users table, the columns are UserID, FirstName, and Email. Every entry in a column is the same type of data.

  • Rows: Rows are the individual records in the table. Each row represents a single item. In our example, the row containing 102, Ben, and ben@email.com is one complete record for a single user.

Basic SQL Syntax

SQL uses straightforward, English-like commands to interact with the database. You write statements, often called queries, to tell the database what you want to do. While there are many commands, they all follow a predictable structure.

A query is simply a request for data or information from a database.

For example, if we wanted to get all the first names from our Users table, the query would look something like this. Notice how it almost reads like a sentence.

SELECT FirstName -- The data you want to get (the column)
FROM Users;      -- Where to get it from (the table)

Understanding tables, columns, and rows is the first step. With this foundation, you're ready to start learning the commands that let you work with them.