English subtitles

← Foreign Keys - Intro to Relational Databases

Get Embed Code
4 Languages

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

  1. First, let's looks at the users table.
  2. A person's full name isn't unique, but
    the user name on the form should be.
  3. So that can serve as a primary key.
  4. Next, the posts table.
  5. Each post has a unique id,
    and that's the primary key.
  6. And author here, seems to refer to
    the users tables, username column.
  7. So that's a foreign key.
  8. Lastly, there's the votes table.
  9. Post_id here seems to refer
    to the id column in posts,
  10. which would make that a foreign key.
  11. In the voter column, refers to
    the username in the user's column.
  12. So that's also a foreign key.
  13. But one more thing,
  14. since each user should only be
    allowed to vote once on each post.
  15. The pair of columns post id
    comma voter in the votes table,
  16. should also be a primary key.
  17. It talks about, for instance, user
    Prince Utena's vote on post_id number 2.