Fireship · @fireship

SQL Explained in 100 Seconds

Uploaded April 6, 2021 · Length 2:23

SQL Explained in 100 Seconds

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.

  1. 0:00

    structured query language sql or sql for

  2. 0:03

    short is the gold standard language for

  3. 0:05

    communicating with relational database

  4. 0:07

    management systems you've likely heard

  5. 0:09

    of databases like mysql

  6. 0:11

    postgres microsoft sql server and oracle

  7. 0:14

    all of which are based on sql with their

  8. 0:16

    own little variations

  9. 0:17

    it was initially developed in the early

  10. 0:19

    70s to mutate and retrieve data from

  11. 0:21

    ibm's system r database by 1986

  12. 0:24

    it was standardized into the syntax that

  13. 0:26

    remains extremely popular in technical

  14. 0:28

    applications today a relational database

  15. 0:31

    organizes data into tables

  16. 0:33

    kind of like an excel spreadsheet where

  17. 0:34

    columns contain attributes or types of

  18. 0:36

    data

  19. 0:37

    while each row represents an individual

  20. 0:39

    record or data point with its own unique

  21. 0:41

    id

  22. 0:42

    known as a primary key we can establish

  23. 0:44

    relationships between data points

  24. 0:46

    by taking the unique id from one row and

  25. 0:48

    storing it on a different row in a

  26. 0:50

    different table

  27. 0:50

    in a special column known as a foreign

  28. 0:53

    key in the teams table the team id

  29. 0:55

    is the primary key but in the players

  30. 0:57

    table it's the foreign key

  31. 0:58

    and what that data structure tells us is

  32. 1:00

    that a player belongs to one team

  33. 1:02

    while a team can have many players what

  34. 1:05

    we've done here

  35. 1:06

    is structured our data in its smallest

  36. 1:08

    normal form to eliminate duplication and

  37. 1:10

    redundancy

  38. 1:11

    now the role of sql is not only to read

  39. 1:14

    create

  40. 1:15

    update and delete data but also to join

  41. 1:17

    data together

  42. 1:18

    based on the relationships embedded

  43. 1:20

    within it the syntax

  44. 1:21

    is comprised of several key parts if we

  45. 1:24

    zoom all the way out

  46. 1:25

    we have a statement or a piece of code

  47. 1:27

    that does something

  48. 1:28

    like reads or writes to the database

  49. 1:30

    within a statement we have a variety of

  50. 1:32

    keywords that can manipulate the

  51. 1:33

    database

  52. 1:34

    select can be used to make a query for

  53. 1:36

    the columns that you want

  54. 1:38

    from a table the column and table names

  55. 1:41

    are known as

  56. 1:41

    identifiers but we may not want every

  57. 1:43

    row in the table so we filter the

  58. 1:45

    results with the where keyword to only

  59. 1:47

    include records that meet a certain

  60. 1:48

    condition

  61. 1:49

    it's like looping over every row in the

  62. 1:51

    table and only returning rows in the

  63. 1:52

    query where the predicate evaluates to

  64. 1:54

    true

  65. 1:55

    then we might use the join keyword to

  66. 1:57

    connect data from an entirely different

  67. 1:58

    table

  68. 1:59

    by matching the primary key on this