How is redundant data avoided in non relational databases? How is redundant data avoided in non relational databases? mongoose mongoose

How is redundant data avoided in non relational databases?


What you describe is normalised data. Normalisation in databases is a characteristic of relational databases. Document-oriented no-sql databases such as MongoDB use a different paradigm where you structure the data around a doucment paradigm. In this world, the data is arranged into documents (JSON structures). You can point to other structures but there is always a tradeoff. You have to decide what level of data redundancy works, but that is really a secondary issue. Your first priority in a MongoDB-like world is to figure out what makes the most sense in the context. For instance, you might have a document representing an Invoice with embedded line items, but also a pointer to a separate customer object. But you might also, in the same database, have a document designed around the customer, that has invoice headers nested, or even invoice lines nested, or invoice headers nested with invoice lines nested inside, or products bought, with or without product catalog information.

Joins are generally expensive in a MongoDB world, but richness of data stored in multiple ways for a range of purposes is a feature well worth using - in the right context.

You should not see MongoDB as a replacement for a relational DBMS, but rather as part of a bigger polyglot (multilanguage) persistence design. You might also use other data tools like Redis and Neo4J as part of that world to do different things.

Horses for courses; MongoDB isn't for everything.