Fireship · @fireship
SQL Explained in 100 Seconds
Uploaded April 6, 2021 · Length 2:23
Summary
sql explained in 100 seconds, including relational databases, tables, primary keys, foreign keys, and basic syntax.
- sql tutorial
- relational databases
- database management systems
- sql syntax
- primary key
- foreign key
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
structured query language sql or sql for
- 0:03
short is the gold standard language for
- 0:05
communicating with relational database
- 0:07
management systems you've likely heard
- 0:09
of databases like mysql
- 0:11
postgres microsoft sql server and oracle
- 0:14
all of which are based on sql with their
- 0:16
own little variations
- 0:17
it was initially developed in the early
- 0:19
70s to mutate and retrieve data from
- 0:21
ibm's system r database by 1986
- 0:24
it was standardized into the syntax that
- 0:26
remains extremely popular in technical
- 0:28
applications today a relational database
- 0:31
organizes data into tables
- 0:33
kind of like an excel spreadsheet where
- 0:34
columns contain attributes or types of
- 0:36
data
- 0:37
while each row represents an individual
- 0:39
record or data point with its own unique
- 0:41
id
- 0:42
known as a primary key we can establish
- 0:44
relationships between data points
- 0:46
by taking the unique id from one row and
- 0:48
storing it on a different row in a
- 0:50
different table
- 0:50
in a special column known as a foreign
- 0:53
key in the teams table the team id
- 0:55
is the primary key but in the players
- 0:57
table it's the foreign key
- 0:58
and what that data structure tells us is
- 1:00
that a player belongs to one team
- 1:02
while a team can have many players what
- 1:05
we've done here
- 1:06
is structured our data in its smallest
- 1:08
normal form to eliminate duplication and
- 1:10
redundancy
- 1:11
now the role of sql is not only to read
- 1:14
create
- 1:15
update and delete data but also to join
- 1:17
data together
- 1:18
based on the relationships embedded
- 1:20
within it the syntax
- 1:21
is comprised of several key parts if we
- 1:24
zoom all the way out
- 1:25
we have a statement or a piece of code
- 1:27
that does something
- 1:28
like reads or writes to the database
- 1:30
within a statement we have a variety of
- 1:32
keywords that can manipulate the
- 1:33
database
- 1:34
select can be used to make a query for
- 1:36
the columns that you want
- 1:38
from a table the column and table names
- 1:41
are known as
- 1:41
identifiers but we may not want every
- 1:43
row in the table so we filter the
- 1:45
results with the where keyword to only
- 1:47
include records that meet a certain
- 1:48
condition
- 1:49
it's like looping over every row in the
- 1:51
table and only returning rows in the
- 1:52
query where the predicate evaluates to
- 1:54
true
- 1:55
then we might use the join keyword to
- 1:57
connect data from an entirely different
- 1:58
table
- 1:59
by matching the primary key on this


