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 - SQL Server Tutorial
From the course: Microsoft SQL Server 2019 Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Understand data types6m 46s
-
Table column properties4m 7s
-
(Locked)
Primary key fields3m 46s
-
(Locked)
Establish a default value4m
-
(Locked)
Check constraints4m 7s
-
(Locked)
Unique constraints5m 39s
-
(Locked)
Foreign keys3m 59s
-
(Locked)
Create a foreign key column3m 30s
-
(Locked)
Create relationships between tables4m 19s
-
(Locked)
-
-
-
-
-
-
-