Introduction to SQL

SQL (Structured Query Language) is a powerful programming language designed for managing and manipulating relational databases.

What is SQL?

  • SQL stands for Structured Query Language
  • SQL lets you access and manipulate databases
  • SQL is an ANSI (American National Standards Institute) standard
  • SQL is the standard language for Relational Database Management Systems
Did You Know? SQL was initially developed at IBM in the early 1970s by Donald D. Chamberlin and Raymond F. Boyce. It was originally called SEQUEL (Structured English Query Language).

What Can SQL Do?

  • SQL can execute queries against a database
  • SQL can retrieve data from a database
  • SQL can insert records in a database
  • SQL can update records in a database
  • SQL can delete records from a database
  • SQL can create new databases
  • SQL can create new tables in a database
  • SQL can create stored procedures in a database
  • SQL can create views in a database
  • SQL can set permissions on tables, procedures, and views

SQL is a Standard - BUT...

Although SQL is an ANSI/ISO standard, there are different versions of the SQL language.

However, to be compliant with the ANSI standard, they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.

Note: Most SQL database programs also have their own proprietary extensions in addition to the SQL standard! Examples include T-SQL (Microsoft SQL Server) and PL/SQL (Oracle).

Using SQL in Your Website

To build a web site that shows data from a database, you will need:

  • An RDBMS database program (like MySQL, SQL Server, PostgreSQL)
  • A server-side scripting language (like PHP, Python, Node.js)
  • To use SQL to get the data you want
  • To use HTML/CSS to style the page

RDBMS

RDBMS stands for Relational Database Management System.

RDBMS is the basis for SQL, and for all modern database systems such as:

  • Microsoft SQL Server
  • MySQL
  • PostgreSQL
  • Oracle
  • IBM DB2
  • Microsoft Access
  • SQLite

The data in RDBMS is stored in database objects called tables. A table is a collection of related data entries and consists of columns and rows.

Example - Simple Table Structure

ID Name Age
1 John Doe 30
2 Jane Smith 25

Key SQL Commands

Here are some of the most important SQL commands you'll learn:

  • SELECT - extracts data from a database
  • UPDATE - updates data in a database
  • DELETE - deletes data from a database
  • INSERT INTO - inserts new data into a database
  • CREATE DATABASE - creates a new database
  • ALTER DATABASE - modifies a database
  • CREATE TABLE - creates a new table
  • ALTER TABLE - modifies a table
  • DROP TABLE - deletes a table
  • CREATE INDEX - creates an index (search key)
What You'll Learn:
  • How to use SQL to query databases
  • How to insert, update, and delete data
  • How to create and modify database structures
  • Best practices for database design