From the course: Learning SQL Server 2017

Unlock the full course today

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

Join tables together with keys

Join tables together with keys - SQL Server Tutorial

From the course: Learning SQL Server 2017

Start my 1-month free trial

Join tables together with keys

- [Narrator] Because we're using primary key columns in our data tables to uniquely identify individual records, we can use this information in other tables to make relationships between them. By formalizing the connections between data tables, we can take advantage of the interconnected nature of the information that's being stored. Let's suppose that we want a new table to collect information about orders and we want to make sure that we know the customer that's placing the order. We can use the CustomerID number in the orders table so that we have an easy way to refer back to the individual that made the purchase. To see this in action, we'll go over to the MyDatabase database and we'll come down to the Tables folder within it. I'll right click on it, point to new, and choose table. We're going to create a new table here for our orders. The first column will be the OrderID. I'll press tab to move over to the data type, and this is going to store an integer data type. So I'll type…

Contents