1. Learn
  2. /
  3. Courses
  4. /
  5. Hierarchical and Recursive Queries in SQL Server

Exercise

Defining primary and foreign keys

A very important concept of relational databases is the use of primary and foreign keys. In this exercise, you will define a two new tables. A table Person, with a PRIMARY KEY and another table, History, with a PRIMARY KEY and a FOREIGN KEY referencing the Person table.

Instructions

100 XP
  • Define the primary key PersonID for Person of type INT.
  • Define the primary key OrderID for History.
  • Define the foreign key PersonID referencing the primary key of Person.