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 a foreign key column

Create a foreign key column - SQL Server Tutorial

From the course: Microsoft SQL Server 2019 Essential Training

Start my 1-month free trial

Create a foreign key column

- To apply the concept of a foreign key column to our Landon Hotel database, I want to create a new table. We already have a table for guests, so it would also make sense if we also had a table that stored room reservations for the guests. I'm going to right click on the tables folder underneath the Landon Hotel database, point to new and then click on table. The first column for this table will be the reservation ID. The data type will be an integer. And I want sequel server to manage my reservation IDs on it's own, so I'm going to turn on the option to create the identify specification. We'll go and throw this open here, change is identify to yes, and I can simply double click on it to change it's option to yes. And we'll leave it there with the identity seed as one and the identify increment as also one. This is going to be the primary key for the table, so I'll come up here to the toolbar and click on the key icon and that finishes the first column. In this column will be the…

Contents