1 00:00:00,090 --> 00:00:05,430 So now that we've seen how to use source, we're going to take advantage of it to get some sample data 2 00:00:05,430 --> 00:00:09,300 going for the next couple of videos and exercises. 3 00:00:09,810 --> 00:00:11,250 Cats are kind of boring. 4 00:00:11,670 --> 00:00:13,200 They're pretty simple at this point. 5 00:00:13,200 --> 00:00:18,480 Name and age and breed, and we need some more complicated data and that's a little something that's 6 00:00:18,480 --> 00:00:19,560 a little more real world. 7 00:00:19,560 --> 00:00:25,200 So we're still not working with something straight out of a production app because we haven't seen some 8 00:00:25,200 --> 00:00:27,360 of the features that we need to know for that to work. 9 00:00:27,360 --> 00:00:32,790 So it's still kind of simplified data, but what we're working with is books data. 10 00:00:33,360 --> 00:00:35,490 So this is what we have. 11 00:00:36,090 --> 00:00:42,000 I've given you this file so you can find it in the file section or of the downloadable section of this 12 00:00:42,000 --> 00:00:42,600 video. 13 00:00:43,590 --> 00:00:50,580 Basically, there's two parts for creating a books table, and I'll go over that in just a second. 14 00:00:50,580 --> 00:00:56,070 And then after that table is created, there's a bunch of values that I'd like for you to insert, and 15 00:00:56,070 --> 00:01:00,240 I didn't want you to have to type these all at once, but I want us to all have the same data as we 16 00:01:00,240 --> 00:01:03,030 can be on the same page when we run exercises. 17 00:01:03,860 --> 00:01:05,960 So all of this data is actually real data. 18 00:01:05,960 --> 00:01:07,990 It's about books from Amazon. 19 00:01:08,000 --> 00:01:13,220 And basically it has every book has a book ID, so that should not be new. 20 00:01:14,030 --> 00:01:15,920 There's a title, it's a bar chart. 21 00:01:16,310 --> 00:01:20,510 Then we have an author, first name and an author last name. 22 00:01:21,110 --> 00:01:23,930 So if we look at one, Here's The Namesake. 23 00:01:23,930 --> 00:01:24,890 That's a title. 24 00:01:25,130 --> 00:01:29,480 The author first name is Jhumpa, and her last name is Lahiri. 25 00:01:30,570 --> 00:01:32,630 Then we have the released year. 26 00:01:32,640 --> 00:01:34,490 So what year was it released in? 27 00:01:34,500 --> 00:01:39,630 And this is an example where we're using kind of the I don't want to say dumbed down but simplified 28 00:01:39,630 --> 00:01:46,080 version of data, because typically you would probably store a date, an actual date, not just a number 29 00:01:46,080 --> 00:01:47,220 like 2003. 30 00:01:47,850 --> 00:01:50,160 So we'll see how to do that once we talk about dates. 31 00:01:50,460 --> 00:01:57,270 But for now, we just have 2003 and then the next thing is stock quantity and this is just an arbitrary 32 00:01:57,270 --> 00:01:58,320 number I picked. 33 00:01:58,950 --> 00:02:03,150 The idea here is that we have a fictional bookshop and we're keeping track of all the books and how 34 00:02:03,150 --> 00:02:04,410 many we have in stock. 35 00:02:04,680 --> 00:02:08,220 So for The Namesake, we have 32 copies in stock. 36 00:02:09,729 --> 00:02:11,710 For a hologram for the king. 37 00:02:11,710 --> 00:02:14,170 We have 154 copies in stock. 38 00:02:15,250 --> 00:02:17,110 Then the final thing is the pages. 39 00:02:17,110 --> 00:02:18,730 How many pages are in that book? 40 00:02:19,270 --> 00:02:25,810 So you can see some books are really long, like The Amazing Adventures of Kavalier and Clay at 634 41 00:02:25,810 --> 00:02:26,440 pages. 42 00:02:26,530 --> 00:02:31,930 And some are much shorter, like what we Talk About When We Talk About Love by Raymond Carver. 43 00:02:32,620 --> 00:02:34,060 Really good short stories, if you like. 44 00:02:34,060 --> 00:02:36,970 Short stories, 176 pages. 45 00:02:37,720 --> 00:02:39,730 So a note about these books. 46 00:02:40,030 --> 00:02:45,940 I started off by just picking off the best sellers on Amazon as of writing today. 47 00:02:45,940 --> 00:02:49,810 So I think that's where this one Norse mythology by Neil Gaiman came from. 48 00:02:49,810 --> 00:02:56,680 But I then just decided to create a variety of ears and page numbers, some of my favorite authors. 49 00:02:56,770 --> 00:02:58,030 It's a whole mix of things. 50 00:02:58,030 --> 00:03:05,020 So it is real world in a sense, but it's also sort of I planned certain things to work certain ways. 51 00:03:05,020 --> 00:03:08,650 So we have certain we have some really long titles and some short titles. 52 00:03:08,650 --> 00:03:10,240 We have some really long books and short books. 53 00:03:10,240 --> 00:03:14,440 We have some books from the 2000 and some from the 1900s and so on. 54 00:03:14,440 --> 00:03:17,260 Basically, I wanted a variety of things that we could practice with. 55 00:03:17,970 --> 00:03:23,770 So go ahead, create a file in cloud nine and put all of this in there. 56 00:03:23,790 --> 00:03:25,230 Now, if you want to type it, go ahead. 57 00:03:25,230 --> 00:03:29,500 But I would recommend that you don't just so that you don't accidentally mess something up. 58 00:03:29,520 --> 00:03:31,410 We want our data to be consistent. 59 00:03:32,070 --> 00:03:33,370 So go ahead, copy it. 60 00:03:33,400 --> 00:03:37,020 Make a new file, and then we need to execute that file. 61 00:03:37,200 --> 00:03:39,930 And I want to make a new database right now. 62 00:03:39,930 --> 00:03:44,540 If we do select database, we're working with Cat app. 63 00:03:44,550 --> 00:03:54,090 I want to create database and we'll call it bookshop and then use bookshop and we should have a blank 64 00:03:54,090 --> 00:03:57,480 slate if we do show tables. 65 00:03:58,530 --> 00:03:59,760 There should be nothing here. 66 00:04:00,750 --> 00:04:01,410 Perfect. 67 00:04:01,740 --> 00:04:07,280 So what you want to do is make sure this file has been saved and then we just execute it. 68 00:04:07,290 --> 00:04:14,100 So it's pretty straightforward source and then you'll need to make sure you either are referencing the 69 00:04:14,100 --> 00:04:15,090 correct path. 70 00:04:15,120 --> 00:04:19,560 So in my case, I'm running my CLI in my root directory. 71 00:04:19,860 --> 00:04:22,470 So all I have to do is book data, SQL. 72 00:04:22,770 --> 00:04:25,200 Whatever you called it, you'll need to refer to. 73 00:04:25,470 --> 00:04:28,010 I recommend just putting it in the main directory for now. 74 00:04:28,020 --> 00:04:33,570 But we could you could have a separate folder if you wanted to and you just need to refer to it correctly 75 00:04:33,570 --> 00:04:34,250 anyways. 76 00:04:34,260 --> 00:04:38,550 Source book data dot SQL. 77 00:04:39,120 --> 00:04:40,020 And here we go. 78 00:04:40,740 --> 00:04:41,550 All right. 79 00:04:41,550 --> 00:04:47,580 First thing, we get this message and that tells us they create table worked and then we get 16 rows 80 00:04:47,580 --> 00:04:48,030 affected. 81 00:04:48,030 --> 00:04:50,220 And that tells us the insert statement worked. 82 00:04:50,850 --> 00:04:52,020 So let's just verify. 83 00:04:52,020 --> 00:04:52,440 Let's do it. 84 00:04:52,440 --> 00:04:54,960 Describe books. 85 00:04:56,220 --> 00:04:57,010 Here we go. 86 00:04:57,030 --> 00:05:03,690 Here's all that we created in that table, and let's just do a simple select star from books. 87 00:05:04,770 --> 00:05:06,360 As you can see, it's pretty messy. 88 00:05:07,260 --> 00:05:08,490 And that's still a. 89 00:05:08,730 --> 00:05:09,990 We're going to work on ways. 90 00:05:10,320 --> 00:05:15,660 We're going to see ways of refining this and making things shorter, collapsing data and so on. 91 00:05:15,960 --> 00:05:18,150 So that's all we're doing in this video. 92 00:05:18,180 --> 00:05:19,680 We're just getting set up. 93 00:05:19,830 --> 00:05:24,210 Now that we have it in there in our database, we'll be able to work with it and be on the same page. 94 00:05:24,330 --> 00:05:24,930 Awesome.