Nosql basic question

Status
Not open for further replies.

Case

Ars Tribunus Angusticlavius
6,756
Hi, I'm an old-school ETL dev who (until now) has only worked with relational dbs. I'm learning about nosql in its various forms, and my company has specifically mentioned dynamoDB (we are moving a lot of infrastructure to Amazon, for better or worse....) Anyway, my question is more of a general query about relation vs any sort of nosql, not anything specific to dynamoDB.

I get that there aren't really foreign keys, and no schema. That said, "child" data is being stored presumably. So my issue becomes: what happens when a piece of data changes value that happens to be used in various attributes (records)? I have several issues that spring to mind, but first since that probably doesn't make sense (likely due to me misusing terminology) I'll give an example.

If you store people's names in various places in the db, what happens when someone changes their name?
The example docs for dynamoDB mention key/value pairs, so I guess it might look like this:
(context of people messaging) - recipient:John Smith
(context of who bought something) - buyer:John Smith

and so on.

So: If John Smith changes his name, you'd have to look for his name in various (unknown) places in every record, replacing the value string with the new name?
Related: Obviously there can be more than one "John Smith". With only a name/value that contains the name, how can we ensure the right John Smith is targeted with our updates?

Do you have another key/value pair for ID everywhere there is a person (or any entity for that matter) to be able to handle this kind of "foreign key" functionality?

Apologies if I'm way off the reservation on this. I am finding that most of the learning material focuses mainly on "scale" and not on this kind of business use, and it's hard for me to learn new things when I immediately think of reasons it might not work ;-) Best I get the answers as the questions occur or they'll nag me :)
 

Violynne

Ars Scholae Palatinae
881
Hi, I'm an old-school ETL dev who (until now) has only worked with relational dbs.

So: If John Smith changes his name, you'd have to look for his name in various (unknown) places in every record, replacing the value string with the new name?
Caution: my knowledge of nosql is limited.

I know you just provided an example, but the obvious question would be: why are you storing the name instead of an identifier?

The example probably isn't the best, but it's important, because most nosql data is identifier driven. If you think of it primarily as a single point in/out type of data driver, it helps to understand.

Because there are no relationships between tables in nosql, you have to create them, and this is where the identifier comes in. Since there are no joins, you have to go into each table and make the necessary updates.

Though, in terms of real use, the user would update their information, not the backend support. Nosql databases are primarily used for SPAs (single page applications), and so it's more about pushing data, and collecting is usually limited to a need-only methodology (new accounts, update info, those kinds of things).

These updates are usually handled through JSON/WebAPIs so separate the task of reading data vs. updating it.

If you're in a situation where the company is thinking "Hey, this is a faster version of SQL", then it may be necessary to tell them to put the brakes on because their lack of understanding is going to cause problems if they don't identify the scope of using nosql in regard to the business logic requirements.

Your nosql database should be designed with the "set and forget it" ideology, putting the control at the user level, not the dba (whose only role will be to monitor performance).

Exceptions apply here, but one of the primary benefits of nosql is much less administration tasks.
 

Case

Ars Tribunus Angusticlavius
6,756
Thanks for the info.

Actually, using an identifier is what would make sense to me (since that's what you'd do with foreign keys in a relational db). It's just that the examples I've seen so far--which are far from "real world" most likely--show things like people's names, product titles etc in the places where I would have normally expected to see IDs or at least codes.

Talking to my company...yeah....
They have a severe case of "ooo shiny" when it comes to the cloud and anything new, period...especially if it's a product shown off by a fancy sales guy. Nothing unique to this company, I'm sure. I'm a senior dev but my pesky attitude of "what is the reasoning for this again?" means I'm pretty much excluded from any decision-making, since that is perceived as trouble-making. :) That sucks quite a bit, but on the bright side I get to learn new things.
 
NoSQL is an umbrella term that encompasses anything that's not SQL. Such as graph stores, tuplestores, kv stores, and document stores. It sounds like you're basically talking about document stores, a/k/a mongo.

The answer is, every single deficiency you think you see in mongo is probably there in mongo. If your data has structure, then Mongo just pushes all of the work of enforcing the invariant of your structure, and codifying relationships, onto you, the developer. Then it says, "looky here, I can get a 2x speedup by doing 1/10th of the necessary work!" Except it doesn't say that to you; its slick salesman goes over your head and says it to your boss's boss. And it leaves off that whole part about the 1/10th of the work. That part is just implied.

So yeah, fuck Mongo. It doesn't solve any problems that people actually have.
 

KallDrexx

Ars Tribunus Militum
2,040
NoSQL databases only shine in very very very specific circumstances and rarely ever shine for a brand new application. These databases require very intimate use cases for querying and writing that are domain and user specific that only become apparent after an application has been in use by real customers for a considerable amount of time.

Most documentDBs claim awesome read/write speed because you can store a ton of information in a single document (like an Album document that stores direct song and artist information in the same document). This is "amazing" because you can show the spotify display in a singe database query.

But now your users are using the application and they want to see all songs by a particular artist. Well now you need to create a brand new index that lists every artist and what album ids they belong to and make sure that stays up to date. Now your users have a playlist of songs and they want to go directly from a song to the ablum that the song is in. Now you need a new index that maps song ids to album ids. Now you want to implement playlists for your users and now playlists contains song ids that reference album ids.

At this point you either end up with a hodge podge of a data model that no one can navigate (cause you started with an album centric system that stores songs and now no one knows where the true source of truth for something is) or you've slowly migrated out to a relational model anyways that has zero of the guarantees of a traditional RDMS.

Even Facebook started and still runs heavily on MySql
 

Josh

Ars Praefectus
3,533
Subscriptor
Nosql databases usually end up being one of several databases in a system.

For example, you might use a cassandra database for your identity service. It would be the central authority for all user account information. Any updates or references would go through this service, and any identity references in other systems would include a reference id that lets you pull the cononical identity record from that system.

Now, if you don't have a use case that requires an identity service, you might want to keep your identity information alongside other application data, which might not fit well into a key value store system, so you might put everything in a rdbms.

But key value stores are just one kind of nosql databases. Another that I've been hearing a lot about are graph databases. My friend was able to quickly and easily create a design in neo4j that allowed him to do queries into relationships between a network of people and the events that they attended in common that would have required rather exotic schematic structures in a relational database.
 

Drizzt321

Ars Legatus Legionis
34,921
Subscriptor++
NoSQL is an umbrella term that encompasses anything that's not SQL. Such as graph stores, tuplestores, kv stores, and document stores.

Yes, NoSQL is a very nebulous term that really includes products with all different sorts of properties and strengths and weaknesses. Heck, you can call Memcached a NoSQL store. Doesn't mean it's great for everything. I don't have experience with many of them, but we're using Redis and Hadoop where I work and I've evaluated a few more systems. Basically, it boils down to properly evaluating what you actually need and what does the particular product actually do to solve that need. And that the weaknesses are manageable by your organization.


Thanks for the info.
Talking to my company...yeah....
They have a severe case of "ooo shiny" when it comes to the cloud and anything new, period...especially if it's a product shown off by a fancy sales guy. Nothing unique to this company, I'm sure. I'm a senior dev but my pesky attitude of "what is the reasoning for this again?" means I'm pretty much excluded from any decision-making, since that is perceived as trouble-making. :) That sucks quite a bit, but on the bright side I get to learn new things.

Heh, so, you're just asking questions that make them feel uncomfortable because they have no clue how "cloud" and "nosql" actually are used and so they want to be able to blame you (or the team in general) when things go down the toilet because of a forced and rushed migration and rollout. Print out copies of all of the emails when you say "but X, Y, Z is a good reason we should go slower to make sure A, B, C won't happen".

On the other hand, if you're a miracle worker you'll be able to learn a ton and won't be blamed for the disasters you manage to avoid.
 

fitten

Ars Legatus Legionis
55,632
Subscriptor++
Hi, I'm an old-school ETL dev who (until now) has only worked with relational dbs.

So: If John Smith changes his name, you'd have to look for his name in various (unknown) places in every record, replacing the value string with the new name?
Caution: my knowledge of nosql is limited.

I know you just provided an example, but the obvious question would be: why are you storing the name instead of an identifier?

And now you have some external identifier management system that gives you identifiers to use as PK and FK and no way to enforce consistency. Joy.
 
I'm a senior dev but my pesky attitude of "what is the reasoning for this again?" means I'm pretty much excluded from any decision-making, since that is perceived as trouble-making. :) That sucks quite a bit, but on the bright side I get to learn new things.

Dang, man... are you me and working here, too? :p

"Why are we doing it this day?" "Hush, we know what we're doing." "Perhaps, but you're gonna 'throw it over the wall' and I'm not going to be able to support it." "Meh."

:grrr:
 
Status
Not open for further replies.