So with everything set up,
I'm back here in this MySQL Workbench
connected to my running MySQL Server.
As we learned in the last lecture,
we now need a bunch of databases
or at least one database to hold the tables
which will then hold our data in the end.
Now, don't forget our plan for this course section
was to actually work on this restaurants use case here
where we have a bunch of restaurants
with the reviews that belong to it.
Therefore, I would like to start by creating a table
for the restaurants data.
And therefore, we first of all need a database.
Now, in MySQL Workbench,
you can go to Schemas here in this tab.
And then there, you can create your databases.
They are also called schemas here in MySQL Workbench,
but these are our databases.
We actually got a database already,
but that's an internal database
that holds some settings for this MySQL Server.
And therefore, we will not use this sys database,
but instead, we can create a new one
by right-clicking in there and choosing Create Schema.
Alternatively, you can also go up here to this icon
and click that to create a new schema.
Now you can give this schema,
so this database a name
and I will name it restaurant_finder.
The name is up to you, but we could be building an app,
a website which may be is called restaurant_finder
because it helps people find and rate restaurants.
And therefore, I give the database
that belongs to that website the same name,
restaurant_finder.
Now here, we can choose a char set and a collation.
In the end, this will influence how characters,
so how text will be stored and the defaults are fine here.
If you wanna learn more about that,
the official SQL docs or a complete SQL course
is the way to go,
but the defaults will make sure that we can store
any kind of characters in our database tables.
And therefore, all we have to do here is click Apply.
Now, what you see on that next screen
is actually the SQL query that will be executed
to create this new database.
So here it's called CREATE SCHEMA
and then our name between those back ticks here.
Now, actually, we could also remove those back ticks.
That would still work.
And instead of SCHEMA, we could also write CREATE DATABASE.
That's also accepted.
Now, speaking of accepted values or commands here,
what you see here as mentioned is SQL syntax
and SQL is all about issuing commands like this
to our database server, to our MySQL Server in this case,
so that the server is then able to execute these commands
and do something based on them.
Of course, for that, we have to follow certain rules
and execute commands the server understands
and there is a long list of built-in commands
the server does understand.
You can check the official docs
if you wanna dive into all the supported commands,
but don't do this right now.
It's overwhelming and most commands are rarely used
or are pure administration commands,
but CREATE DATABASE is one of the commands
the SQL Server understands,
and it does what the name implies.
It creates a database of a given name.
Now, you can execute multiple SQL statements together.
Here, we only have one,
but we could add more in that box here
and they are then separated by semicolons
like you see it here at the end of the line.
You don't need that semicolon
if you only have one command that will be executed.
But if you, for example, want to create a database
and then in a second step
already create a table in that database
and you wanna execute that in one go,
then you could put that table creation command
below this command and separate them with semicolons.
But here, we're going to create a table
in a separate second step in a couple of seconds.
So this is SQL syntax.
Now, what's worth noting here is that CREATE and DATABASE
are written all uppercase.
Technically, that's not required.
CREATE and DATABASE in this combination are keywords
that will be understood by the SQL Server
no matter if you write them uppercase or not,
but it's a convention to use all caps notation here
to make it clear for us humans and for other developers
that these are reserved keywords
so that these are built-in commands
and that restaurant_finder in this case
is the only flexible value that's up to us in this command.
That's why the built-in keywords and commands
are typically written all uppercase when working with SQL
and that's then how the SQL language looks like.
It's definitely different than what we had in JavaScript.
It's also new that we just issue commands like that
and we don't write a file full of code
that is then executed,
but it makes sense if you think about what we're doing.
With our NodeJS code or our frontend code,
we of course had to write code
that can be evaluated by a browser
or that can act as a web server,
so code that can handle multiple incoming requests.
Here, we have a one-time task. We wanna create a database.
So that's just one thing that needs to be done.
And therefore, we write query commands like this
to issue these one-time tasks to the database server.
And therefore, SQL always looks like this.
There's a broad bandwidth of built-in commands,
but we always issue them like this,
possibly multiple commands at the same time,
separated by semicolons,
but we issue them like this
so that the server can then execute them
and do whatever we tell the server to do.
And therefore, long story short,
now we have this instruction defined here
and we can now click on Apply here to execute it
and send this command to the SQL Server
so that on that SQL Server,
that database will be created.
And therefore here on the left,
we now see this database here.
And in that database, we now also have tables
or at the moment we have no tables,
but we have the capabilities to analyze this database
and look at our tables once we have some.
And speaking of that,
that's therefore the next step I wanna dive in.
I wanna create a new table.