1 00:00:00,000 --> 00:00:09,150 [MUSIC] 2 00:00:09,150 --> 00:00:13,185 Hi, my name is Megan, and I'm a teacher here at Treehouse. 3 00:00:13,185 --> 00:00:18,990 In this workshop we're going to dive into relational databases using SQLAlchemy. 4 00:00:18,990 --> 00:00:22,610 Make sure you're familiar with SQLAlchemy before moving on. 5 00:00:22,610 --> 00:00:24,990 Check the prerequisites and teacher's notes below. 6 00:00:26,160 --> 00:00:30,790 Before we jump into the code, let's chat about what relational means. 7 00:00:32,110 --> 00:00:34,910 Let's think about a real-life scenario. 8 00:00:34,910 --> 00:00:39,256 Let's say you work for a small business, you probably have a list, or 9 00:00:39,256 --> 00:00:42,214 spreadsheet, or database of your customers. 10 00:00:42,214 --> 00:00:44,616 Now, if a customer makes a purchase, 11 00:00:44,616 --> 00:00:48,074 you might think about adding on to the table like this. 12 00:00:49,788 --> 00:00:56,521 But over time, this would probably get confusing and hard to follow. 13 00:00:56,521 --> 00:01:00,292 Instead, you can break this up into two tables, and 14 00:01:00,292 --> 00:01:03,560 then create a relationship between the two. 15 00:01:04,990 --> 00:01:08,900 In the second table, you can see there is a column for the customers ID. 16 00:01:09,950 --> 00:01:15,390 IDs are always unique, since this is the primary key of the customer table. 17 00:01:15,390 --> 00:01:17,700 This is called a foreign key. 18 00:01:17,700 --> 00:01:21,870 It lets your database know there's a relationship between these two tables. 19 00:01:22,930 --> 00:01:26,360 These foreign keys are shared attributes between the tables. 20 00:01:27,850 --> 00:01:31,400 Now that we have a quick overview of a relational database, 21 00:01:31,400 --> 00:01:35,830 I find playing around in the code helps solidify the knowledge. 22 00:01:35,830 --> 00:01:40,180 So in the following videos, let's create our own relational database. 23 00:01:40,180 --> 00:01:43,200 Don't forget to check the teacher's notes as you go. 24 00:01:43,200 --> 00:01:44,190 Let's get started.