1 00:00:00,490 --> 00:00:04,340 In this video, we'll be looking at one more type of table relationship. 2 00:00:04,340 --> 00:00:06,570 The one to one relationship. 3 00:00:06,570 --> 00:00:09,100 A one to one relationship between two tables 4 00:00:09,100 --> 00:00:13,080 means that one row from one table can only relate to one row 5 00:00:13,080 --> 00:00:17,680 on the other table at the other side of their relationship and vice versa. 6 00:00:17,680 --> 00:00:21,610 In practice, you don't see this type of relationship very often. 7 00:00:21,610 --> 00:00:24,330 But there are a few occasions when you might. 8 00:00:24,330 --> 00:00:28,710 Here you can see the one to one relationship between table A and table B. 9 00:00:28,710 --> 00:00:34,480 Notice that the ID's one, two, and three appear only once in each table. 10 00:00:34,480 --> 00:00:37,360 While there is nothing technically wrong with this design, 11 00:00:37,360 --> 00:00:42,210 in practice, it is usually better to just combine these two tables into one. 12 00:00:43,360 --> 00:00:48,630 This is because all non ID columns depend solely on the ID column 13 00:00:48,630 --> 00:00:53,140 A once one design might come in handy though separating the frequently and 14 00:00:53,140 --> 00:00:58,050 infrequently used columns can boost performance by reducing the overhead 15 00:00:58,050 --> 00:01:01,100 to access the most frequently used columns. 16 00:01:01,100 --> 00:01:05,350 Say you have a database that was purchased from a third party vendor, and 17 00:01:05,350 --> 00:01:08,180 you're not allowed to modify their tables, but 18 00:01:08,180 --> 00:01:12,580 you want to extend the functionality of your application by adding columns. 19 00:01:12,580 --> 00:01:17,110 You would create a new table to extend the functionality of the core table. 20 00:01:17,110 --> 00:01:20,230 Let's take a look at an example that uses a one-to-one 21 00:01:20,230 --> 00:01:22,590 relationship to extend a table. 22 00:01:22,590 --> 00:01:26,740 There we have a customer table that sits in a third party database, 23 00:01:26,740 --> 00:01:30,970 that our company is purchased when not allowed to modify the structure 24 00:01:30,970 --> 00:01:34,570 of the core table but we want to add a few columns. 25 00:01:34,570 --> 00:01:36,490 We could create a second table and 26 00:01:36,490 --> 00:01:40,530 call it something that identifies as a sibling to the customer table. 27 00:01:40,530 --> 00:01:43,340 Like Customer_ Extension, 28 00:01:43,340 --> 00:01:46,880 we give it the same primary key as the original customer table. 29 00:01:46,880 --> 00:01:52,440 This field ID is also the foreign key back to the customer table then we can 30 00:01:52,440 --> 00:01:57,840 add new columns we want in this case phone and date of birth this relationship 31 00:01:57,840 --> 00:02:02,890 between the core customer table and the new extension table is one to one.