SQL Fundamentals
Introduction to SQL
What Is SQL?
Imagine a library with millions of books, all perfectly organized. To find a specific piece of information, you can't just wander around; you need to ask the librarian. The librarian understands your request and retrieves exactly what you need. In the world of data, a relational database is like that library, and SQL is the language you use to speak to the librarian.
SQL stands for Structured Query Language. It's the standard language for interacting with relational databases, which are databases that organize data into tables, much like spreadsheets.
SQL (Structured Query Language) is a standard programming language used for managing and manipulating relational databases.
With SQL, you can ask a database to perform specific tasks: retrieve data, add new records, update existing information, or delete entries. It's the tool that turns raw data into useful insights.
A Brief History
SQL wasn't born overnight. Its story begins in the early 1970s at IBM. Researchers Donald D. Chamberlin and Raymond F. Boyce developed it after learning about the relational model for databases from Edgar F. Codd. Their goal was to create a simple, English-like language to manage the data in this new type of database.
The first version was called SEQUEL (Structured English Query Language), but the name was later shortened to SQL. Because of its power and relative simplicity, it quickly gained popularity. By the 1980s, it was standardized by the American National Standards Institute (ANSI) and the International Organization for Standardization (ISO). This standardization is key—it means that while different database systems might have minor variations, the core SQL commands work almost everywhere.
The Structure of a Statement
An SQL command is called a statement. Think of it as a complete sentence that tells the database what to do. Most statements are built from a few key components.
- Keywords: These are reserved words that have a special meaning, like
SELECT,FROM, andWHERE. - Identifiers: These are the names of your tables and columns, like
CustomersorLastName. - Clauses: These are parts of a statement that start with a keyword, like
FROM Customers.
Let's look at a basic query. Say we have a table named Employees and we want to find the names of all employees in the 'Sales' department.
SELECT FirstName, LastName
FROM Employees
WHERE Department = 'Sales';
Let's break that down:
SELECT FirstName, LastNametells the database which columns you want to see.FROM Employeesspecifies which table to look in.WHERE Department = 'Sales'filters the results, showing only the rows where theDepartmentcolumn has the value 'Sales'.
The semicolon at the end marks the completion of the statement. It tells the database that your command is finished and ready to be executed. Every SQL statement you write will follow a similar, logical structure.
Now that you understand the basic purpose and structure of SQL, let's test your knowledge.
