Repetition of Data in NoSQL Document Database

All we need is an easy explanation of the problem, so here it is.

This is a very "noobish" question, but I’m working on a project with a document database and I think they are using it wrongly. Thus, I kinda want to confirm this, as I feel it is tainting my experience.

In a nutshell, they seem to have brought a relational mindset to a document paradigm.
For example, instead of embedding a particular JSON object in another, they are pulling them together in the business layer via ids (smells very much like foreign keys to me).

Now, it’s true that repetition of data is avoided here (hey, as a SQL guy, I’m all about 3rd normal form), but I thought that having the data in there as part of the bigger document was more important than avoiding repetition of data.

I get that there are probably trade-offs and it may not be wise to have huge objects that contain everything, but I was hoping for a bit of guidance as to what is the best way to do things in this space and whether this place (probably) has it it wrong. (NoSQL is challenging if the blind is leading the blind).

Thanks

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

NoSQL is generally designed to store a denormalized data object as a way to persist it and eliminate the need for JOINs as a way to optimize for read performance.

But that doesn’t mean JOINs aren’t allowed in a NoSQL context, just so much as persisting denormalized and duplicated data is allowed in a traditional relational database context. They’re just generally not the primary design focus of each of those types of databases, respectively.

My guess is you’re probably correct that there’s more of a flawed mindset in how your partners are designing the project, since they’re JOINing in the application layer, but it really depends on your use cases.

Shape of data manipulations should generally be done proactively and persisted in NoSQL databases when possible, as your thinking is, but it doesn’t always have to be persisted ahead of time and operations (such as JOINs) that are traditional in a RDBMS aren’t always bad in a NoSQL database either.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply