Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
In this lesson, we will build on the information we learned about Keys and Constraints to explain the concept of linking, or relating, tables in a database system.
One to Many relationships are by far the most common type of table relationship. There is a wealth of information about One to Many relationships available.
Here are a few of the links we find most helpful:
[MUSIC] 0:00 In the previous stages, we learnt about the high level concepts such as database 0:04 normalization and set theory. 0:08 We also learned about database keys and 0:11 how they are used to create database relationships. 0:13 Now, we're going to explore table relationships more in depth. 0:17 There are three types of relationships between tables. 0:21 They are called one to one, one to many, and many to many. 0:24 These types are described by how many rows can be related to each other 0:29 on either side of the relationship. 0:33 One to many relationships are by far the most common type of relationship, 0:36 that you'll encounter in database design. 0:40 This type of relationship means that one row in one table can be related to many 0:43 rows in another table at the other side of the relationship, but not vice versa. 0:48 The many can only happen in one direction. 0:53 Take this Sales Table for example, 0:57 it has a foreign key to the product table on the column ProductID. 0:59 When describing this relationship you could say, a Sale has 1 product but 1:04 a Product can be a many sales. 1:09 If you ever get confused as to which side is the foreign key, 1:12 an easy trick to remember is that the foreign key always goes on the many side. 1:17 In this example there are many instances of the ProductID, 145 on the Sale Table. 1:22 That's the many side, thus that's the foreign key. 1:29 In our next video, we'll take a look at the next type of relationship. 1:33
You need to sign up for Treehouse in order to download course files.Sign up