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

Create a foreign key column

- [Instructor] To apply the concept of a foreign key column to our Red30 tech database, I want to create a new table. We have a table for customers, and we also have a table for products. So it would make sense if we had a table for orders where we could store information about the products that specific customers have ordered. Let's right click on the table's folder, point to new, and choose table, and that'll start up a new table design window. The first column is going to be the order ID. We'll store this as an int data type, and I do not want to allow nulls, so I'll turn that checkbox off. Then down in the properties, I want to apply the identity specification property so I'll find that and twirl it open. I'll change the is identity property to yes, and I'll leave the seed and increment both set to one. I also want this order ID to be the primary key for the table, so I'll come back up here to the top and click the…

Contents