From the course: Microsoft SQL Server 2019 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create relationships between tables

Create relationships between tables - SQL Server Tutorial

From the course: Microsoft SQL Server 2019 Essential Training

Start my 1-month free trial

Create relationships between tables

[Instructor] - Now that we've created a link between the data that's in the Landon Hotel guest table and the room reservations table, the last step in creating a relationship between the primary key and the foreign key 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 table's for us, so that we don't need to manually have to look up values from one table to the other. We do this in the table on the foreign key side of the relationship, so I'm going to right click on the room reservations table and open it in the designer. Then, up on the toolbar, I'm going to click this icon here for relationships. It looks like two different tables that are connected by a join line. That'll open up the foreign key relationships window. Then, I'll come down to the bottom left and click the Add button to create a new Foreign key relationship. Then, I need to…

Contents