No history yet

Introduction to SQL

What Is SQL?

Imagine a giant digital filing cabinet. This cabinet doesn't just store files; it organizes them into neat tables with rows and columns, much like a spreadsheet. This special filing cabinet is called a relational database. To ask this cabinet to find, add, or update information, you can't just shout at it. You need to speak its language. That language is SQL.

SQL

noun

Stands for Structured Query Language. It's the standard programming language used to communicate with and manage data in a relational database.

SQL lets you perform all sorts of tasks. You can retrieve specific data, like finding all users who live in California. You can insert new records, update existing ones, or delete information that's no longer needed. It's the universal tool for talking to most of the world's databases.

SQL (Structured Query Language) is a language used for managing relational databases.

A Quick History

SQL wasn't born overnight. It was developed at IBM in the early 1970s by Donald D. Chamberlin and Raymond F. Boyce. They originally called it SEQUEL, which stood for Structured English Query Language. The name was later shortened to SQL due to a trademark issue.

Because it was so effective, it quickly gained popularity. In the 1980s, it was adopted as a standard by both the American National Standards Institute (ANSI) and the International Organization for Standardization (ISO). This standardization is key. It means that while different databases might have their own minor variations or "dialects," the core SQL language works pretty much the same everywhere.

The Heart of Relational Databases

So, what makes a database "relational"? The name gives it away: it's all about relationships. A relational database stores data in tables. You can think of each table as a single, well-organized spreadsheet.

user_idfirst_namelast_nameemail
1AliceSmithalice.smith@email.com
2BobJohnsonb.johnson@email.com
3CharlieBrowncharlie@email.com

Each table has columns (like user_id, first_name) and rows, which represent individual records. The real power comes from creating relationships between tables. For example, we might have another table for product orders. We can link an order to a user through the user_id.

This link is a relationship. It allows us to ask complex questions, like "Show me all products ordered by Bob Johnson." SQL is the language we use to frame these questions.

Speaking the Language

An instruction you give to a database is called a statement or a query. SQL statements are composed of a few key ingredients. They almost always start with a command word, like SELECT, INSERT, UPDATE, or DELETE.

Let's look at the most common command, SELECT. It's used to retrieve data. A basic query to get all the data from our Users table would look like this:

SELECT * FROM Users;

Let's break that down:

  • SELECT is the action. It tells the database you want to retrieve data.
  • The asterisk (*) is a wildcard that means "all columns."
  • FROM Users specifies the table you want to get data from.
  • The semicolon (;) marks the end of the statement. It’s not always required, but it's good practice to use it.

One last thing: SQL keywords like SELECT and FROM are not case-sensitive. select * from Users; would work just fine. However, capitalizing them is a common convention that makes queries much easier to read.

This is just the beginning. With SQL, you can filter, sort, and combine data in powerful ways, all using simple, English-like commands.

Quiz Questions 1/5

What is the primary purpose of SQL?

Quiz Questions 2/5

SQL was originally developed in the 1970s under a different name. What was it?