YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Queries and Results - Intro to Relational Databases

Get Embed Code
4 Languages

Showing Revision 4 created 05/25/2016 by Udacity Robot.

  1. Earlier, I told you that database
    tables were a lot like the tables you
  2. might see in an infographic or
    a reference book.
  3. There are some differences though.
  4. One of these is important when there
    are multiple answers to a question,
  5. which will often be the case just before
    we use a count or another aggregation.
  6. This table is about animals and
    what they eat.
  7. Unlike some tables we've seen before,
    this one sometimes has
  8. the same value in some of the cells
    with different values over here.
  9. This is how we say things like
    brown bears eat fish and meat and
  10. plants in a database table.
  11. We split that sentence out
    into multiple sentences,
  12. which make multiple rows in the table.
  13. Why don't we just make
    multiple columns or
  14. put several values in one column
    separated with commas or something?
  15. There are lots of
    reasons not to do that.
  16. If we tried using multiple columns for
    the different foods each animal eats,
  17. we wouldn't know how many
    columns to make in advance.
  18. Some animals do eat a lot more kinds
    of foods than others after all.
  19. And what's more, we want to be able
    to use counts and other aggregations.
  20. And those will only work if we have
    our data separated out into rows,
  21. not jammed together.
  22. Now let's take a look at a real
    database query against this table.
  23. Select food from diet where
    species equals orangutan.
  24. This looks almost like ordinary English,
    but
  25. this is actually an SQL database query.
  26. It's asking the database to return
    particular data from the diet table.
  27. In a moment, we'll run this
    query using an actual database.
  28. But before we do,
    can you figure out which rows and
  29. which columns from this
    table it will return?