From the course: SQL Server 2014 Essential Training

Unlock the full course today

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

Creating relationships between tables

Creating relationships between tables - SQL Server Tutorial

From the course: SQL Server 2014 Essential Training

Start my 1-month free trial

Creating relationships between tables

- Now we have two tables in our database, the Orders table and the People table. I'd like to create a relationship between those two tables. SQL Server is a relational database system. Meaning it supports relationships between these tables. We're going to create a relationship such that the PersonID field in the Order's table is always populated with a valid value from the People table. In order to do this, we'll first need to make that field the People ID field, we'll need to make that a key in the People table. I'll open up the People table. We'll look at the columns. Again we have PersonID. That's the one we want to make into a key. So I'll right-click on the People table and go to Design. I'll highlight the PersonID column and in Management Studio on the lower toolbar, the second icon from the left has an icon that looks like a key, and so if we click on that it will turn this column into the key for this table. That is signified by having the little key icon next to the name of…

Contents