Module - 4
Module - 4
A) A document database is a type of NoSQL database designed to store, retrieve, and
manage document-oriented information, which is typically represented as JSON-like
documents. Unlike traditional relational databases (RDBMS), document databases allow
each "document" (similar to a row in an RDBMS) to have a unique structure. This
flexibility makes document databases well-suited for applications requiring a schema that
can adapt over time
Example:
{
"firstname": "Martin",
"likes": [ "Biking", "Photography" ],
"lastcity": "Boston",
"lastVisited":
}
The above document can be considered a row in a traditional RDBMS. Let’s look at
another document:
1. Looking at the documents, we can see that they are similar, but have
differences in attribute names.
2. This is allowed in document databases. The schema of the data can differ
across documents, but these documents can still belong to the same
collection—unlike an RDBMS where every row in a table has to follow the
same schema.
4) When document databases are not suitable (When Not to Use) ? Explain.
❖Flexible schema means that the database does not enforce any restrictions
on the schema.
❖Data is saved in the form of application entities. If you need to query these
entities ad hoc, your queries will be changing (in RDBMS terms, this would
mean that as you join criteria between tables, the tables to join keep
changing).
❖ Since the data is saved as an aggregate, if the design of the aggregate is
constantly changing, you need to save the aggregates at the lowest level of
granularity—basically, you need to normalize the data. In this scenario,
document databases may not work.