Okay.
So in this video, we're going to talk about how you actually create new databases in my SQL finally.
So before we go into the code, let's set the stage just a little bit.
Currently, we have a MySQL database server represented by this box that's running on our Cloud nine
instance.
So that's what happened when we did the My SQL CTL start that started up the database server.
So now the command that I'm going to show you is what allows us to create individual databases inside
of the My SQL database server.
So hypothetically, we could have a database for a dog walking app, another one for a soap shop.
We could have a practice database if you were just practicing some new code, some new lines of SQL
you wanted to try out.
And maybe there's a new site database and they're all hosted.
They're all part of the same database server, but they're individual databases inside.
And that's really important.
And to understand why.
Let's zoom in a little bit on two of the databases, our dog walking app database and a soap shop database.
So inside of those two databases, we'll store various entities or different data.
So in the dog walking database will probably need to store information about dogs.
And in our soap shop database, we'll need to store something about soaps.
And then here's where it gets really important.
Our dog walking app likely has users, but so does our soap shop app.
And our dog walking app has payments and so does our soap shop app.
So they have to be separated.
If we just had one database that everything was using on this server, there would be a lot of crossover
in.
There would be issues.
What if you had somebody who had the same name, who used your dog walking app and they also use the
soap shop app and they kind of the streams got crossed, if you will.
That's problematic.
So what we're going to learn now is how to create these individual walled off databases inside of the
SQL Server we have running.
Okay.
So let's take a look at some code.
This first line here we've already seen before.
All that it does is list the current databases that exist in the My SQL Server.
So when we do it right now, if I need to start up my SQL, CTL, CLI and I type show databases, we
get this list of the five pre-existing ones that we have nothing to do with.
We didn't create these manually.
The next piece of code is create database, followed by the name of the database you'd like to create.
So in this course, whenever there's a variable, I'll use these brackets to signify that it's just
a placeholder.
So in this case, whatever the name of your database is, and then a semicolon.
So to make a database for our soap store, we might name it Soap Underscore Store or for our dog app.
We could use dog app and you don't have to use underscores.
You can capitalize things if you would like.
There's no rules governing that.
Exactly.
However, if you did something like this, well, it can work.
It's just not a good idea to do it.
So that gets Xed out.
I don't recommend doing it.
Actually, my recommendation is to stick with this here.
What's called snake case.
Everything's lowercase and just use underscores instead of spaces, but it's totally up to you.
Like I said, there's not a hard rule and what's more important is that you are just consistent.
So whatever you choose, just make sure that you continue to use that just to avoid any confusion.
So let's hop over to a terminal and give it a shot.
So I'm going to just make my first database
and I will call it Hello World.
DB and remember that semicolon.
And if we wanted to make sure that it worked, we can just run that show databases command again.
Now you'll see a new edition.
Hello, World DB.
A note about capitalization when I wrote Create Database.
Yes, you can get away with doing create database.
Hello.
And let's call this one testing DB.
That works just fine.
So whenever you see those capitalized letters in SQL commands, you do not have to use them.
But I like to use them and a lot of people like to use them just to signify what comes from SQL and
then what is a custom name.
So in this case, testing DB is something I wrote or Helloworld DB is a database name or a table name
down the line or a column name once we get there.
And we can tell that because it's not capitalized and then create database is in all caps, it tells
us that's just regular old SQL.
So that's pretty much it to creating a database that doesn't really give us very much, but we've basically
made a space on the server where we can add data.
We just don't know how to do that yet.
So we've just partitioned off a little area and we've given it a name of Helloworld.
DB or in our second example, testing DB.