SQL Server: Foreign Key

Level : Beginner
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:25:00

Lab Details

Description

A Foreign Key is a constraint that is placed on a column. This constraint specifies that a matching value must exist in another table. It can effectively links two tables together. A table can have any number of foreign keys.

In this lab, you will learn how to make a Foreign Key in table in SQL Server.

Based on this Customer and Supplier Schema, generate the solutions to the respective queries listed below:

  1. Creating an Order table with a foreign key referencing the Customer table.
  2. Write a query that combines the records from two tables. The JOIN should match the foreign key with the primary key in another table.
  3. Add a Foreign key to an existing table.
  4. Drop a foreign key from Order table.

Lab Objective

Upon completion of this lab, you will be able to:

  • Gain Hands-On Experience on SQL Server Foreign keys

Prerequisites

  • You should have a conceptual understanding of Keys and Constraints.
  • You must have SQL Server Installed on your systems.


Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this