All companies store data from a simple record book of a small business maybe even on a journal or a
piece of paper.
Two massive companies like Amazon that need computers to store petabytes of data now in order to store
this information.
Pretty much every company and sometimes individuals too need something called a database.
We saw in the last section how hard it was to have our server.
Remember a new user.
Every time the server crashed the variable would get reset and then it would start all over.
Or if we wanted to do a log in or assign and check and iterate through the emails and passwords.
Doing a loop through javascript that's inefficient.
That's where database come to the rescue so let's ask ourselves what is a database.
A database is a collection of data and what we mean by data.
There are many forms of them right.
There can be numbers that can be dates.
There could be password hashes.
There could be user information databases allow us to organize this data in a way that is useful to
us and it makes data management easy and something came out of that.
And it's called database management system or D.B. M.S. for short it's a collection of programs which
allows us to access databases and work with data.
And it also allows control access to database users so a DB M.S. is something in this box something
that allows us a tool or piece of software that allows us to communicate with the database store information
that's useful for us and also allows us to update insert delete look up whatever is in the database.
And this idea of a DB M.S. really started to take shape in 1960s and now it is at the forefront of many
exciting things.
There's an entire industry of engineers that just work with databases because it is so important.
Now there are two types of DNS that are really popular right now and that we're going to talk about
in this course and these two types are represented really well by post scripts and Mongo DB.
Let's talk about the first one which is relational database and this is probably the most popular as
you can see on the right hand side you see that all of these are relational databases post graphs Oracle
Eskew all server you may have heard of my ask you I'll ask you a light these are all types of databases
that have this relational database tag to them and the beauty with them is that they're all pretty much
similar.
They all follow a same standard format relational databases consist of two or more tables with columns
and rows so in this case users is a table and a full name user name text created at our columns and
whatever values they have here are rows each row represents an entry in each column sorts a very specific
type of information like name address or phone numbers and then the relation between tables and field
is called a schema in a relational database the schema must be clearly defined before any information
can be added and if this is confusing right now don't worry we're actually going to create these databases
so it makes sense to you.
If we had Twitter for example you can see over here the types of tables that we would have and how we
would organize it.
We would have a user stable a tweet table a following table and we can connect all these information
for example by connecting different pieces of the table.
For example the user name will be the same in the user's table as it is in the tweets table.
That way we can say that the user name and the tweets table is the foreign key of the user name in the
user's table and then from user will be the foreign key of user name in the following table now things
like full name or I.D. something that identifies each row in a table is called a primary key.
And we'll go through that later on in the section
all right.
So all these databases we're going to learn about post crisis.
Q Well but they're all pretty much the same.
So once you know on it's fairly easy to pick up the other ones how do they actually communicate with
a server with the backend.
Well all relational databases use something called ask you out
and ask you all allows us to communicate just like a CTP did between the front end and the back end.
With Eskew all we're able to communicate with the database and modify or get or update however we want
and we'll have a video on this topic as well.
All right so that's relational databases.
What about the second type.
The second type is called a non relational database or a no ask you out database.
And once again there are many many different types of databases with some cool names like how HDB and
hyper table now a mongo D.B. or a non relational database lets you build an application without having
to define the schema first unlike a relational database if we go back to relational database.
This schema or these tables have to kind of be predefined right.
We need to know how our app is going to look make these tables so that once the app is public we can
start entering user information and tweets and followers with a no Eskew all or non relational database
we can just define it as we go.
And they all have different ways of storing this information so each one is very very different.
And this is another powerful reason to use a non relational database is that if your data requirements
aren't clear at the outset of your project and maybe you have a massive amount of unstructured data
you may not have the luxury of developing a relational database with a clearly defined schema they offer
instead a greater flexibility in that a non relational database are more like folders just assembling
related information of all types now Mongo D.B. is something called document oriented It stores information
as documents.
Let me illustrate this point to you.
I have my desktop here with two folders.
One is a really relational database.
And here I have users tweets profile following and you can think of relational databases with this type
of storage where this folder lived somewhere on a computer that stores this information.
And anytime we need to ask a database for something well we grab the users and if we also want to grab
the tweets of the user we find the user that we're interested in then find the tweets of the user that
we're also interested in with the foreign key that links to the users and we can also find however many
followers that user has.
We grab that information and display it on our web app Mongo D.B. on the other hand will actually have
each user as a document so if I wanted to grab the first user Well I just grab this document and it
has all the followers the tweets the profile everything is in this one document and you might be thinking
Mongo D.B. looks like a better choice than having this way of doing things right.
Well it depends on your need and that's why databases is such a complex topic.
It really really depends on your situation.
You can see this Mongo D.B. way being very useful if you had something like a profile maybe a LinkedIn
profile.
But if you needed something where you're working was just following data or just tweets data maybe with
the tweets you want to see what is the average tweet size.
Well it's really easy to just grab this file and calculate that versus this way where you might have
to extract it from each one of the users.
So it really depends on your needs me show you another diagram that might be useful where we look at
relational versus non relational databases you can think of relational as each table has a blog post
a blog tag a blog comment and it links these tables to give you the blog information versus a non relational
that stores this entire blog post in an entry and has comments tags categories and all other related
data just in one single place.
So what does Mongo D.B. use to communicate if we go back to our example here.
We had asked you all for relational databases such as post press or mongo D.B. has its own what we call
query language and it is just the Mongo D.B. query language
but they both aim to do the same thing that is to communicate with the database provide an easy way
for the server to communicate with the database and in this section we're gonna be talking about that
and we're going to finally connect the dots and show you the power of databases once they're connected
to a server I'll see you in the next one.
But Bye.