From the course: Microsoft SQL Server 2022 Essential Training

Unlock this course with a free trial

Join today to access over 24,100 courses taught by industry experts.

Create relationships between tables

Create relationships between tables

- [Instructor] Now that we've created a link between the data in the Red30 Tech customers orders and products tables, the last step in creating a relationship between the primary key and foreign key columns is to tell SQL Server what we've built. We need to formalize the relationship so that it can be recognized by the database engine. This will enable SQL Server to follow the threads between the tables for us so that we don't manually have to look up values from one table to another. We do this in the table on the foreign key side of the relationship. In our case, that means the orders table. I'll right click on it and open it up in the designer. Then on the toolbar, find the relationships button. It's this icon here with the two tables that are linked with a little plus symbol. Go ahead and click that and it opens up the foreign key relationships window. Next at the bottom, press the add button and…

Contents