SQL-101-Basics
  • Introduction
  • Part 1: Transact-SQL
    • 1.0: Getting Started with T-SQL
    • 1.1: Create Database
    • 1.2: Drop Database
    • 1.3: Create Table
    • 1.4: Insert
    • 1.5: Update
    • 1.6: Read
    • 1.7: Alter
    • 1.8: Customer Table
    • 1.9: Diagramming Notation
    • 1.10: Foreign Keys
    • 1.11: Join
    • 1.12: Solutions
  • Part 2: PostgreSQL
    • 2.0: Getting Started with PostgreSQL
    • 2.1: Create Database
    • 2.2: Drop Database
    • 2.3: Create Table
    • 2.4: Insert
    • 2.5: Update
    • 2.6: Read
    • 2.7: Alter
    • 2.8: Customer Table
    • 2.9: Diagramming Notation
    • 2.10: Foreign Keys
    • 2.11: Join
    • 2.12: Solutions
  • Part 3: T-SQL Challenges
    • 3.0: Introduction
    • 3.1: Challenge 1
    • 3.2: Challenge 2
    • 3.3: Challenge 3
    • 3.4: Challenge 4
    • 3.5: Solutions
  • Part 4: PostgreSQL Challenges
    • 4.0: Introduction
    • 4.1: Challenge 1
    • 4.2: Challenge 2
    • 4.3: Challenge 3
    • 4.4: Challenge 4
    • 4.5: Solutions
  • Part 5: Resources
    • 5.0: Resources
Powered by GitBook
On this page
  1. Part 1: Transact-SQL

1.10: Foreign Keys

Previous1.9: Diagramming NotationNext1.11: Join

Last updated 7 years ago

Now, you're going to learn about foreign keys and primary keys. Click 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 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 . 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
here
this link
1.12 Solutions
Purchase Table Challenge
Purchase Table Result