So, what's the problem?
Why do we need such a database thing?
Well, up to this point in the course,
when we stored data permanently,
we always stored it in files.
We simply wrote data into a file,
and when we needed that data,
we read it from that file.
That's what we did before,
we write data to a file,
we fetch data from a file.
And then we might filter that fetched data
for a specific ID for example,
as we did it here for restaurants,
where we then went through all the fetched restaurants
to get a specific restaurant,
but we always interacted with the file system
just like that.
Now, whilst that worked,
it's not great because when we create data
and we always replace the entire content of a file
with the new data,
or when we read data and we then always read
the entire file content just to then loop through it
and find a specific element.
Or if we might want to update or delete data,
and for that,
we also read the entire content to then find the element
we wanna update or delete,
then update the entire data and write it back.
If we always do it like this,
then this is pretty inefficient
because we always overwrite everything,
we always read everything,
and that of course,
we're explore various simple demo projects and websites,
but if our website grows and we have more and more data,
that will simply lead to performance issues and our code
will do unnecessarily much work.
As a side note,
the operations we see here,
creating, reading, updating and deleting,
are very common and therefore commonly referred
to as CRUD operations.
And you will see them over and over again
throughout the course and especially,
also throughout the next sections,
which are about databases.
But back to this problem here.
It's pretty inefficient
if we always work with all the data
and it's not just inefficient because we work
with too much data,
because we could try to do that more efficiently.
When working with files as we did it here,
we don't have to read the entire file.
We don't have to write the entire file.
NodeJS and other programming languages
give us tools that would allow us to read parts of a file
or write two parts of a file.
So, we could optimize that.
But as I said,
it's not just the inefficiency in our bulk operations
that we have at the moment,
but instead in addition,
we can simply run into scalability issues
as our data size grows,
as we have more, more data.
And if we have more and more requests
coming into our server,
we can also run into issues
because we can have concurrent file access
where because of 10 incoming requests,
we try to write to exactly the same file 10 times
at the same point of time.
So, we could have multiple read and/or write operations
targeting the same file at the exact same point of time.
And that could cause us big issues
where reading then fails or writing fails,
or we accidentally overwrite data from another request
because we have two requests coming in
at the same point of time.
And in addition,
we also might overwhelm our computer, our system
as a whole,
or at least the file system
if we have too many concurrent read and write operations.
So, as our website grows and handles more and more visitors,
we can face more and more issues
if we store and retrieve data,
as we did it up to this point.
Therefore, that was great for getting started
with backend development,
but it's typically not how you would store
and fetch your data in real websites.
And that's where databases help us.
That's why databases are super important,
and part of basically any website you're building.
Because database management systems or DBMS
are simply software systems,
so, software you install on some system,
you could say,
that are optimized for data storage tasks,
under the hood,
they will still store data and files at some point,
but they do it in a way more efficient way,
taking away all the heavy lifting of managing file access
and concurrent read and write access from you,
and allowing you to just work with your data
without having to worry about how that data
is then written to a file or how it's fetched from a file.
So, database management systems
help us by optimizing read-write access,
by taking away that pain from us.
They help us by simply optimizing
how data is stored and retrieved
to make that more efficient,
and don't overwhelm our files system
and they optimize data querying
by helping us with rich queries,
by giving us specific query languages
that allow us to find specific pieces of data
in a large chunk of data with these,
so that we have to write less code
for the same or even more work
that we want to do in our website.
And therefore, database management systems
are a must use if you have a website
where you are storing and fetching data.
And turns out,
that many websites do that in some form.
Now, there are many database management systems
you could use.
There are many providers, free ones and paid ones,
but there are two main kind of systems
in the end that you can use.
And then for each system,
you'll have plenty of possible database software solutions
to choose from,
but there are two main kinds of databases in the end.
And that would be relational database management systems,
also often called SQL databases.
And SQL often is translated with structured query language,
which means that SQL stands for structured query language.
And you can use that,
but actually it's not coming from that.
It's not an acronym for that.
Instead, SQL originally was called Sequel written like this,
and then it was just shortened to SQL basically.
Now, that's just a side note.
It is a programming language kind of,
that is built for getting data from databases
and storing data in databases or in general,
a language for talking
to such relational database management systems.
That's what SQL is.
And that is what we will learn from this course.
But besides such SQL databases
that use this programming language
for fetching data and writing data,
we also have non-relational database management systems,
which typically are called NoSQL databases
because there,
you store your data differently.
It's structured differently inside of the database
and you don't use the SQL language for fetching your data
or for writing your data,
but instead, different query languages.
And these are the two main kinds of systems.
And in the next lectures,
I'll walk you through the basics of these two systems,
and I'll give you a first comparison of these two systems.
In this course however,
we'll then have entire sections for both systems
so that you get a detailed introduction to both systems
so that you can then also use either system
for your upcoming websites.