MongoDB for Developers with Python Transcripts
Chapter: What is NoSQL?
Lecture: Types of NoSQL databases
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
So this historical description indicates that there are
0:03
a variety of different types of NoSQL databases that we've arrived at,
0:07
basically different levels or types of trade-offs that you might make
0:11
to encourage this horizontal scalable, cluster friendly type of data.
0:15
Now, if you go and look this up, what are the types of NoSQL systems
0:18
you'll see there are four distinct types,
0:21
but I think that would be four types under the not only SQL style systems
0:26
which as that my contention, that's not what NoSQL is.
0:30
So, I think there's actually three types of NoSQL databases
0:33
and then there's another thing that is not SQL; we'll talk about the four.
0:37
So at the most basic, basic level, the simplest ones are
0:41
I'm going to basically create a distributed dictionary
0:44
with id key that I can look up and some opaque blob that I can get back
0:49
so here is some thing, it could be text, it could be binary object, graph,
0:54
it doesn't really matter, store to this key
0:57
and if I ask for that key back give me the thing,
0:59
so for example, I want to store a user and all the stuff
1:03
that is associated with user into a single blob in Redis,
1:06
and when I ask for it back by user id, giving that thing back.
1:11
That means frequently these databases, these key value stores
1:14
don't let you query inside the opaque blob, even if it's text,
1:18
the idea is you query by the id, you get the thing,
1:21
but you can't easily ask it questions like
1:25
what is the average price of the order
1:28
of all the customers stored in your key value store.
1:31
Now, there are ways to add like additional metadata
1:34
that you can stick on to them, so you can sort of fake it a little bit on some of them
1:38
but in general, I can ask for the thing by a key
1:42
and I get a blob that's opaque to the database back.
1:45
Now, these are not great as databases in terms of general purpose databases
1:49
because you can't ask them a wide variety of interesting questions.
1:53
However, they are great in terms of this cluster ability
1:56
of the distributed cash type of thing there is super, super fast,
2:01
because every single query is just finally one item
2:04
by primary key and get it back to me
2:08
so if you horizontally scale that out, you can find
2:10
which key range maps to which server,
2:12
go to that server get it by id— boom, super, super fast.
2:15
So these are nice, they are often used for caches and things like this.
2:19
Next, we have what I think is the real sweet spot for NoSQL databases,
2:25
the ones that potentially could replace
2:27
traditional relational databases in your application,
2:30
that is they are flexible and powerful enough to be general purpose databases
2:35
and that's the document databases.
2:37
So this is MongoDB, CouchDB, OrientDB,
2:40
DocumentDB from Microsoft Azure, things like that,
2:43
so this is really where we going to focus
2:46
almost this entire class, so we'll come back to this.
2:49
We also have a more interesting type of database
2:52
called a columnar database, traditional relational database systems
2:56
like MySQL, Microsoft SQL server etc, store data in rows,
3:01
but a column oriented database is different
3:04
in that it stores data and its tables as columns instead of rows;
3:07
so it's in a lot of ways really similar to relational databases,
3:11
but you'll find that it's easier to kind of associate
3:14
what you might think of is like a pre-joint data,
3:16
maybe some orders, and maybe the orders have order items
3:19
and there's a bunch of those, so you might have one order
3:22
with multiple items, it's easier to group those together in a columnar database.
3:26
But they're kind of more or less like relational databases in a lot of ways.
3:30
So these I believe are the three types of NoSQL databases.
3:32
There's a fourth that often gets grouped here,
3:35
so let's talk about it— graph databases.
3:37
So graph databases let you model relationships
3:40
on many, many small interconnected things
3:44
so think of like social graphs, friends, the pictures,
3:48
the people who have shared that picture, you've liked that picture,
3:52
the friends of your friends who have liked that particular picture
3:55
you can traverse these relationships incredibly easy in graph databases
3:59
because you can actually query directly on the relationships.
4:03
Show all the things related in this way to this item and so on,
4:06
but that does not lead to this cluster friendly sort of thing,
4:09
in fact, this leads to being even more tightly connected
4:12
the less easy to map across multiple
4:15
horizontally scaled servers and things like that.
4:18
So in my mind, the graph databases are super interesting
4:21
but they're not NoSQL they're just not-SQL.
4:25
So that leaves us with three types—
4:27
key value stores, document databases and columnar databases.
4:30
So let's now continue on to talk about document databases.