Introduction to SQL

What is SQL? What do we used it for?

This module will provide an introduction to Structured Query Language, or SQL (pronounced "sequel"). SQL is a programming language that facilitates storing, retrieving, or manipulating specific information from databases. With its relatively simple syntax and power to access/organize great quantities of data, SQL is often one of the top languages used by business and data analysts to retrieve information.

Data is stored in tables which are identified in SQL by their names. SQL applies loops, filtering, functions, and then ordering and limiting the data to manipulate the table into the desired final output. Clauses such as "select", "from", "where", and "order by" are used to do so!

Say we have a table "dogs" that contains information about the dogs at a Berkeley animal shelter. This table contains information about the dog's name, breed, and age (in months).

Name

Breed

Age (years)

Louis

French Bulldog

13

Lucy

Yellow Lab

2

Bailey

Beagle

1

Charlie

Border Collie

4

Milo

German Shepherd

6

Joe

Beagle

15

Now, say we wanted to filter this data so that we only have the dogs whose breed is Beagle. We could use SQL to do so!

select * from dogs where breed = "Beagle";

The output of this code would be a table that looks something like the following.

Name

Breed

Age

Bailey

Beagle

1

Joe

Beagle

15

Don't worry about understanding this code yet! This page is solely meant to introduce you to this module on SQL and give you an idea about how we can use SQL in data science!

Last updated