Now before we're going to explore what exactly we're going
to build in this core section,
and before we are going to start planning how we build it,
let me answer one important question.
Why exactly is this section about connecting to a database,
from inside our backend website code?
Why not from the front end?
Why not, why a JavaScript in the browser?
Well, there is a rule,
and I will explain why we have that rule in a second,
but the rule is that you should not, not, connect to
a database from inside your frontend JavaScript code.
So not from inside the code that runs
in the browser in the end.
Now, why is that the case?
The reason for that is, that since it runs in the browser,
so in the end on the computers of your website visitors,
that code, any JavaScript code that runs in the browser
is in the end, exposed to your website visitors.
Of course the average visitor will not see it.
The average visitor will just see
the result of that code being executed,
but if you're a bit more experienced, like you already are,
you could open the developer tools and in there,
if you click through the different tabs and so on,
you can also view the client side, so to browser side,
to JavaScript code,
that was loaded for a given website,
and that is executed for that website.
So any JavaScript code that's running in the browser
can be viewed by the visitors of your website.
And even more than that, it cannot just be viewed,
visitors could also edit the code that runs in the browser.
This feature exists for debugging reasons,
so that if you are working on your own website,
if you are developing a website,
you could change the code in the browser
to temporarily test a change,
but that is something visitors can do themselves as well.
Now, normally that is no problem,
because if visitors added the code that runs on the website
that was loaded for them, they can only hack themselves,
they can't do any harm to you or to other visitors.
But this changes if you start connecting to a database,
from inside your client's side code,
because then since that code is exposed and editable,
the visitors of your website could, for example,
look up your database credentials.
So the username and password, with which you're connecting
to the database, and they could also manipulate
the queries that are executed,
they could start deleting your tables,
where the data in your tables, when they actually shouldn't
be allowed to do so.
That's why you don't want to have any code that interacts
with your database in the client side, JavaScript code.
That's why we instead, always do that on the backend.
So in our server side JavaScript code with node JS,
because that code runs on our servers that belong to us,
the developer, and this code that runs on the server side,
can't be viewed by the visitors of our website.
That's really, really important.