1.10: Foreign Keys

Now, you're going to learn about foreign keys and primary keys. Click here to watch a video introducing these concepts. SQL Server is used in the video instead of Visual Studio, so the specific steps to set up tables and keys are different. However, the underlying concept is the same and can be applied to T-SQL. After watching the video, you can follow this link to read about establishing constraints with T-SQL.

Use what you've learned to complete the following exercise. Replace the XXXXXXXXs with the correct information to complete the query below:

To see the solution for this challenge, click on 1.12 Solutions. Once you have double-checked your solution, run the query in Visual Studio and refresh your database. You should see a "Purchases" table, which you'll use in the next lesson.

Then, continue to Part 1.11: Join.

Last updated