Skip to content

Document Databases (NoSQL)

Roberto Fronteddu edited this page May 20, 2024 · 1 revision

Document Databases (NoSQL)

Best Use Cases:

  • Unstructured/Semi-structured Data: Ideal for data that does not fit into a strict schema.
    • Example: User Profiles: Social media platforms store user profiles, which can have various attributes and change over time. Document databases like MongoDB allow for flexible schemas to accommodate these changes.
  • Flexibility: Schema-less design allows for easy modification and evolution of data structures.
  • Scalability: Designed for horizontal scaling, distributing data across multiple servers.
    • Denormalization doc db often store related data within a single document, reducing the need for complex join operations. This denormalization means that data can be retrieved in a single read operation, which is more efficient and easier to distribute across nodes.
    • Sharding designed with sharding (partitioning data across multiple servers) in mind. Each shard operates as an independent unit, making it simpler to distribute data and load across multiple servers. This horizontal partitioning allows the database to handle large volumes of data and high traffic more efficiently.
    • eventual consistency models given enough time without new updates, all copies of the data across a distributed system will converge to the same value. It is a model that prioritizes availability and partition tolerance over immediate consistency.

Limitations:

  • ACID Transactions: Limited support for multi-document ACID transactions. Some document databases offer eventual consistency rather than strong consistency.
    • Example: Financial Applications: Applications requiring strong transactional guarantees, such as banking apps, might struggle with the eventual consistency model of some document databases.
    • Complex Queries: Less efficient for complex joins and relationships compared to relational databases.
      • Example: Advanced Reporting: Generating reports that involve complex joins and aggregations across different types of data might be less efficient in a document database.

Why Another Might Be Better:

  • Relational Databases: Better for applications requiring strong consistency, complex transactions, and extensive use of joins and complex queries.
    • Example: Enterprise Resource Planning (ERP) Systems: ERP systems manage a company’s business processes, requiring strong transactional integrity and complex query capabilities, making relational databases a better choice.
  • Graph Databases: More efficient for querying deeply interconnected data and performing graph traversals.
    • Example: Fraud Detection: Detecting fraud in financial transactions involves analyzing relationships and patterns across multiple entities. Graph databases can efficiently model and query these relationships.
Clone this wiki locally