# 2.10: Foreign Keys

Now, you're going to learn about foreign keys and primary keys. Click [here](https://www.youtube.com/watch?v=TpKcAmaaBts) to watch a video introducing these concepts. SQL Server is used in the video instead of pgAdmin, so the specific steps to set up tables and keys are different. However, the underlying concept is the same and can be applied to PostgreSQL. After watching the video, you can follow [this link](https://www.postgresql.org/docs/9.2/static/ddl-constraints.html) to read about establishing constraints with PostgreSQL.

Use what you've learned to complete the exercise below. Replace the **XXXXXXXX**s with the correct references to complete the query below:

![Purchase Table Challenge](https://1712903417-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAU8YgF0bbt1vxBgc5B%2F-LAU8dTUP51jQtyZvnhQ%2F-LAU8ouu18ngpCLp0bhY%2F2.10postgres1.png?generation=1524162319778657\&alt=media)

To see the solution for this challenge, click on [2.12 Solutions](https://eleven-fifty-academy.gitbook.io/sql-101-basics/2.12-solutions#210-foreign-keys-solution).\
&#x20;Once you have double-checked your solution, run the query in pgAdmin and refresh your database. You should see a "Purchases" table, which you'll use in the next lesson.\\

![Purchase Table Result](https://1712903417-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAU8YgF0bbt1vxBgc5B%2F-LAU8dTUP51jQtyZvnhQ%2F-LAU8ovH0Tzl7d0TE8Pl%2F2.10postgres2.png?generation=1524162319862925\&alt=media)

Then, continue to [Part 2.11: Join](https://eleven-fifty-academy.gitbook.io/sql-101-basics/part-2-postgresql/2.11-join).
