SQL Intro
What is SQL?
SQL stands for Structured Query Language. SQL is used to communicate with a relational database. With SQL you can read data from tables, insert new rows, update existing rows, and delete rows you no longer need.
Most database-driven websites and applications rely on SQL behind the scenes. Even if you use an admin panel or an ORM, SQL is the foundation that makes data queries possible.
What Can SQL Do?
- Retrieve data from a database
- Filter, sort, and group data to answer questions
- Insert new records and update or delete existing records
- Create tables, views, and indexes
- Define rules using constraints (for example, primary keys and foreign keys)
- Control access to data with permissions (depending on the database system)
Using SQL in Your Web Site
On a typical web site, SQL is used on the server side. Your application code (for example PHP) sends SQL queries to the database server, receives results, and then renders HTML for the browser.
A common flow looks like this:
- User requests a page (for example, a product list)
- The server runs a SQL query to fetch the needed data
- The server formats the result into HTML and sends it back to the browser
Example: SQL Query in a Web App
This query returns product names and prices above a given value, ordered from highest to lowest:
SELECT name, price FROM products WHERE price > 100 ORDER BY price DESC;
RDBMS
RDBMS stands for Relational Database Management System. It is a type of database system that stores data in tables (relations). Tables contain rows (records) and columns (fields).
The relational model helps you structure data cleanly and connect related information using keys. For example, an orders table can reference a customers table using a customer_id value.
Tables, Rows, and Columns
- Table: a collection of related data (for example, customers)
- Row: one record in the table (one customer)
- Column: one property of the data (for example, email)
SQL and Different Database Systems
SQL is a standard, but database systems can differ in syntax and features. For example, some systems use LIMIT to restrict rows, while others use TOP. In this tutorial we focus on the common core and highlight differences when needed.
Next Step
Continue with SQL Syntax to learn the basic structure of SQL statements and how queries are written.