1 00:00:00,000 --> 00:00:04,268 [MUSIC] 2 00:00:04,268 --> 00:00:08,929 In the previous stages, we learnt about the high level concepts such as database 3 00:00:08,929 --> 00:00:11,500 normalization and set theory. 4 00:00:11,500 --> 00:00:13,890 We also learned about database keys and 5 00:00:13,890 --> 00:00:17,100 how they are used to create database relationships. 6 00:00:17,100 --> 00:00:20,010 Now, we're going to explore table relationships more in depth. 7 00:00:21,120 --> 00:00:24,590 There are three types of relationships between tables. 8 00:00:24,590 --> 00:00:28,390 They are called one to one, one to many, and many to many. 9 00:00:29,660 --> 00:00:33,830 These types are described by how many rows can be related to each other 10 00:00:33,830 --> 00:00:36,490 on either side of the relationship. 11 00:00:36,490 --> 00:00:40,650 One to many relationships are by far the most common type of relationship, 12 00:00:40,650 --> 00:00:43,480 that you'll encounter in database design. 13 00:00:43,480 --> 00:00:48,160 This type of relationship means that one row in one table can be related to many 14 00:00:48,160 --> 00:00:53,340 rows in another table at the other side of the relationship, but not vice versa. 15 00:00:53,340 --> 00:00:56,010 The many can only happen in one direction. 16 00:00:57,130 --> 00:00:58,900 Take this Sales Table for example, 17 00:00:59,940 --> 00:01:04,570 it has a foreign key to the product table on the column ProductID. 18 00:01:04,570 --> 00:01:09,880 When describing this relationship you could say, a Sale has 1 product but 19 00:01:09,880 --> 00:01:12,490 a Product can be a many sales. 20 00:01:12,490 --> 00:01:17,060 If you ever get confused as to which side is the foreign key, 21 00:01:17,060 --> 00:01:22,360 an easy trick to remember is that the foreign key always goes on the many side. 22 00:01:22,360 --> 00:01:29,890 In this example there are many instances of the ProductID, 145 on the Sale Table. 23 00:01:29,890 --> 00:01:33,680 That's the many side, thus that's the foreign key. 24 00:01:33,680 --> 00:01:37,930 In our next video, we'll take a look at the next type of relationship.