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 - SQL Server Tutorial
From the course: Microsoft SQL Server 2022 Essential Training
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…
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
-
-
-
-
-
-
Choose appropriate data types2m 46s
-
(Locked)
SQL Server data type options7m 19s
-
(Locked)
Automatically assign record identities4m 54s
-
(Locked)
Primary key fields4m 35s
-
(Locked)
Establish a default value5m 1s
-
(Locked)
Check constraints5m 10s
-
(Locked)
Unique constraints6m 23s
-
(Locked)
Foreign keys4m 16s
-
(Locked)
Create a foreign key column5m 16s
-
(Locked)
Create relationships between tables5m 6s
-
-
-
-
-
-
-