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


Talk Python's Mastodon Michael Kennedy's Mastodon