Now, let's move on to NoSQL databases.
The idea here for storing your data
is a totally different one than in SQL databases.
Instead of working with a lot of tables in NoSQL databases
you typically work with only a few tables.
For example, you could have one big flights table,
and then in there you are storing documents
that contain all the data you wanna store,
so instead of working with columns and rows
as you know it from a SQL database,
here we now store data
for example, in the JSON format,
where we actually have standalone documents
that contain all the data that belongs to a single document.
Now therefore, of course in this concrete example here
we also have a lot of data duplication,
for example, data about the airports is duplicated
across multiple documents,
but this might not necessarily be a problem,
if you are duplicating data that's not changing a lot
and airports data typically doesn't change a lot
because the airport is not suddenly going to move
into a different city then this might be fine
because you never need to touch that duplicate data.
And then the advantage of storing such bigger records
into one table could be,
if I shrink this a bit
that you could store more information in fewer tables
and therefore get more information with fewer queries.
If I'm interested in all the data
that belongs to a special flight code
I could get the entry for a given flight code,
like one, two , three
and if I then fetch the entire data that's attached to it
I automatically get all the start
and destination airport data as well.
I don't need to connect multiple tables for that,
I don't need to run a complex query across multiple tables,
instead I run one query for one field the flight code
and I get all the data that's related to it,
and that can be a huge benefit
because that can simplify your queries
and therefore in the end also improve database performance
because less complex queries have to be executed.
The size of the stored data might become a bit bigger,
but storing big amounts of data is not necessarily a problem
instead, typically the performance bottleneck
is the querying of data,
and that can be simplified with NoSQL databases
because more data is stored together.
So unlike in SQL databases
with NoSQL you don't think in columns and rows,
but instead you have objects or documents
that are stored in a table,
and you also don't have a clearly set schema.
In this example here,
all the entries in the flights table
happened to have the same structure,
but since we have standalone documents, no columns
you can have different structures in different documents
in the same table,
so one of these flights here could,
for example not have a destination airport
and we could still store it in the same database table
as our other flights,
because there is no schema
you have to set and define at the beginning.
So that's the idea behind NoSQL databases.
Now it comes down to personal preference
and knowledge and experiences,
which of the two approaches you find to be more intuitive,
especially if you have worked with SQL databases before
then NoSQL approach can look a bit strange,
but both approaches have their advantages and disadvantages.
And therefore in the next lecture
I wanna compare the two approaches and give you some ideas
on which approach might be best for which situation.