system
Given the following post, respond as if you're commenting on Reddit:
human
I just don't get NoSQL databases

Perhaps it's just because of my years of working with relational databases, but for the life of me I can't figure out how a non-relational database works.  I've read a number of tutorials and whatnot, and I understand that they are supposed to be faster and more suited for certain use-cases, but I can't really see how.

The Amazon Dynamo DB tutorial, for example, is a movie database.  If I wanted to store a cast list for a movie, I see no other way than an array of strings for each cast member.  But then if I wanted all the movies an actor was in, I'd have to either do what I suspect is some very slow iteration through all the movies' actors, or store that information in the actor table.  But now my data is doubled up and I can't see how that wouldn't create problems.

You might point out that I've tried to use a non-relational database to store a relation, but I can't imagine a database where some sort of relation isn't necessary.  Take Amazon, for example.  There's a million relationships they must be tracking--purchase to user, review to purchase, item to manufacturer, whatever.  

Any insight would be appreciated!
gpt
document based databases are really much faster at looking up individual records than relational databases. so, the primary use cases are things like caches (you're just storing blobs of data by a hash) and if your db ever gets large enough to where you're having trouble scaling your server(s) up (these no-sql dbs tend to be much better at scaling horizontally because they're not designed to store relations between multiple types of data).

the second case is what kind of triggered the craze. facebook switched to using a document based no-sql database to load friends data, if i remember correctly. the data is relational, but they traded duplication of data for lookup speed. they really just needed a key subset of user data in order to populate your friends list, but using a traditional relational database, joining on their 2 billion row user table wasn't very practical. so, they basically store a document for your profile or whatever with the relevant user data duplicated in it. they can shard that data however they want into multiple db instances and just route your request to the correct one and essentially get instant lookups of the data they need to display your profile to you.

however, most dbs will never get to the point where you need to do this type of thing. tons of people switched to using something like mongo because they thought it was the thing to do and ended up biting themselves in the ass because they were still trying to use it like a relational database. they would've probably saved themselves a lot of trouble if they just spun up a postgresql instance or whatever that would easily handle the load and amount of data they had.

edit: there are also things like Hadoop (big table databases) which are designed to just accept as many writes of data as possible. rebuilding indexes and such can be problematic to performance if you're trying to write billions of rows of data per minute. querying these tend to be a bit slower though, so most of the time you'll just write operations to aggregate data sufficiently enough to where you can shove it into a more standard relational database to actually work with the data.