1 00:00:00,180 --> 00:00:00,610 Okay. 2 00:00:00,960 --> 00:00:07,860 So in this video, we're going to talk about how you actually create new databases in my SQL finally. 3 00:00:08,520 --> 00:00:12,330 So before we go into the code, let's set the stage just a little bit. 4 00:00:12,360 --> 00:00:20,550 Currently, we have a MySQL database server represented by this box that's running on our Cloud nine 5 00:00:20,550 --> 00:00:21,330 instance. 6 00:00:21,780 --> 00:00:29,160 So that's what happened when we did the My SQL CTL start that started up the database server. 7 00:00:29,520 --> 00:00:35,250 So now the command that I'm going to show you is what allows us to create individual databases inside 8 00:00:35,250 --> 00:00:37,560 of the My SQL database server. 9 00:00:38,100 --> 00:00:45,960 So hypothetically, we could have a database for a dog walking app, another one for a soap shop. 10 00:00:47,010 --> 00:00:52,140 We could have a practice database if you were just practicing some new code, some new lines of SQL 11 00:00:52,140 --> 00:00:53,190 you wanted to try out. 12 00:00:54,030 --> 00:00:57,750 And maybe there's a new site database and they're all hosted. 13 00:00:57,750 --> 00:01:02,940 They're all part of the same database server, but they're individual databases inside. 14 00:01:02,940 --> 00:01:04,260 And that's really important. 15 00:01:04,260 --> 00:01:05,580 And to understand why. 16 00:01:05,760 --> 00:01:13,020 Let's zoom in a little bit on two of the databases, our dog walking app database and a soap shop database. 17 00:01:13,410 --> 00:01:18,400 So inside of those two databases, we'll store various entities or different data. 18 00:01:18,420 --> 00:01:23,010 So in the dog walking database will probably need to store information about dogs. 19 00:01:23,010 --> 00:01:27,210 And in our soap shop database, we'll need to store something about soaps. 20 00:01:27,630 --> 00:01:29,360 And then here's where it gets really important. 21 00:01:29,370 --> 00:01:35,370 Our dog walking app likely has users, but so does our soap shop app. 22 00:01:35,700 --> 00:01:40,440 And our dog walking app has payments and so does our soap shop app. 23 00:01:40,560 --> 00:01:42,800 So they have to be separated. 24 00:01:42,810 --> 00:01:48,180 If we just had one database that everything was using on this server, there would be a lot of crossover 25 00:01:48,180 --> 00:01:48,360 in. 26 00:01:48,360 --> 00:01:49,230 There would be issues. 27 00:01:49,230 --> 00:01:54,990 What if you had somebody who had the same name, who used your dog walking app and they also use the 28 00:01:54,990 --> 00:01:59,040 soap shop app and they kind of the streams got crossed, if you will. 29 00:01:59,280 --> 00:02:00,390 That's problematic. 30 00:02:00,390 --> 00:02:07,200 So what we're going to learn now is how to create these individual walled off databases inside of the 31 00:02:07,470 --> 00:02:09,150 SQL Server we have running. 32 00:02:09,150 --> 00:02:09,660 Okay. 33 00:02:09,660 --> 00:02:11,130 So let's take a look at some code. 34 00:02:11,460 --> 00:02:14,330 This first line here we've already seen before. 35 00:02:14,340 --> 00:02:19,740 All that it does is list the current databases that exist in the My SQL Server. 36 00:02:19,740 --> 00:02:29,730 So when we do it right now, if I need to start up my SQL, CTL, CLI and I type show databases, we 37 00:02:29,730 --> 00:02:33,660 get this list of the five pre-existing ones that we have nothing to do with. 38 00:02:33,690 --> 00:02:35,400 We didn't create these manually. 39 00:02:35,400 --> 00:02:42,600 The next piece of code is create database, followed by the name of the database you'd like to create. 40 00:02:42,600 --> 00:02:49,710 So in this course, whenever there's a variable, I'll use these brackets to signify that it's just 41 00:02:49,710 --> 00:02:50,490 a placeholder. 42 00:02:50,490 --> 00:02:54,630 So in this case, whatever the name of your database is, and then a semicolon. 43 00:02:54,810 --> 00:03:03,120 So to make a database for our soap store, we might name it Soap Underscore Store or for our dog app. 44 00:03:03,120 --> 00:03:06,810 We could use dog app and you don't have to use underscores. 45 00:03:06,810 --> 00:03:09,240 You can capitalize things if you would like. 46 00:03:09,240 --> 00:03:10,920 There's no rules governing that. 47 00:03:10,920 --> 00:03:11,870 Exactly. 48 00:03:11,880 --> 00:03:16,770 However, if you did something like this, well, it can work. 49 00:03:16,770 --> 00:03:18,840 It's just not a good idea to do it. 50 00:03:18,990 --> 00:03:21,060 So that gets Xed out. 51 00:03:21,240 --> 00:03:22,620 I don't recommend doing it. 52 00:03:23,250 --> 00:03:26,220 Actually, my recommendation is to stick with this here. 53 00:03:26,240 --> 00:03:27,780 What's called snake case. 54 00:03:27,780 --> 00:03:33,810 Everything's lowercase and just use underscores instead of spaces, but it's totally up to you. 55 00:03:33,840 --> 00:03:38,490 Like I said, there's not a hard rule and what's more important is that you are just consistent. 56 00:03:38,490 --> 00:03:43,920 So whatever you choose, just make sure that you continue to use that just to avoid any confusion. 57 00:03:44,190 --> 00:03:46,980 So let's hop over to a terminal and give it a shot. 58 00:03:46,980 --> 00:03:49,530 So I'm going to just make my first database 59 00:03:52,560 --> 00:03:55,890 and I will call it Hello World. 60 00:03:56,550 --> 00:03:59,880 DB and remember that semicolon. 61 00:04:01,500 --> 00:04:06,630 And if we wanted to make sure that it worked, we can just run that show databases command again. 62 00:04:08,290 --> 00:04:10,090 Now you'll see a new edition. 63 00:04:10,120 --> 00:04:11,550 Hello, World DB. 64 00:04:12,850 --> 00:04:16,690 A note about capitalization when I wrote Create Database. 65 00:04:16,690 --> 00:04:19,720 Yes, you can get away with doing create database. 66 00:04:20,440 --> 00:04:20,920 Hello. 67 00:04:20,920 --> 00:04:24,040 And let's call this one testing DB. 68 00:04:26,170 --> 00:04:28,000 That works just fine. 69 00:04:28,420 --> 00:04:33,760 So whenever you see those capitalized letters in SQL commands, you do not have to use them. 70 00:04:33,760 --> 00:04:39,220 But I like to use them and a lot of people like to use them just to signify what comes from SQL and 71 00:04:39,220 --> 00:04:41,350 then what is a custom name. 72 00:04:41,350 --> 00:04:48,250 So in this case, testing DB is something I wrote or Helloworld DB is a database name or a table name 73 00:04:48,250 --> 00:04:51,340 down the line or a column name once we get there. 74 00:04:51,850 --> 00:04:58,390 And we can tell that because it's not capitalized and then create database is in all caps, it tells 75 00:04:58,390 --> 00:05:00,190 us that's just regular old SQL. 76 00:05:01,450 --> 00:05:07,030 So that's pretty much it to creating a database that doesn't really give us very much, but we've basically 77 00:05:07,030 --> 00:05:10,920 made a space on the server where we can add data. 78 00:05:10,930 --> 00:05:12,640 We just don't know how to do that yet. 79 00:05:12,640 --> 00:05:16,810 So we've just partitioned off a little area and we've given it a name of Helloworld. 80 00:05:16,810 --> 00:05:20,260 DB or in our second example, testing DB.