Câu hỏi phỏng vấn NoSQL
Câu hỏi

What does Document-oriented vs. Key-Value mean in context of NoSQL?

Câu trả lời

In the context of NoSQL databases, "Document-oriented" and "Key-Value" refer to two different types of data storage models, each with its own characteristics, advantages, and use cases.

Document-oriented Databases

Characteristics

  • Data Structure: Document-oriented databases store data in documents, which are typically JSON, BSON, XML, or YAML formats. Each document contains key-value pairs but can also include nested structures and arrays, making them suitable for complex and hierarchical data.
  • Collections: Documents are grouped into collections, which are analogous to tables in relational databases. However, documents within a collection can have different structures.
  • Querying: These databases provide rich querying capabilities, allowing users to query based on the content of the documents. They support complex queries, indexing, and even full-text search.
  • Schema Flexibility: Document-oriented databases do not require a fixed schema, allowing for flexible and dynamic data models.

Examples

  • MongoDB
  • CouchDB
  • Elasticsearch

Use Cases

  • Content Management Systems: Suitable for storing and querying complex, nested, or heterogeneous data such as web content, social media posts, and e-commerce product catalogs.
  • Analytics Platforms: Useful for applications requiring complex queries and data aggregation.

Advantages

  • Flexibility: Can handle diverse and evolving data structures.
  • Rich Queries: Supports advanced querying and indexing capabilities.
  • Ease of Use: Natural fit for applications using JSON-like data structures.

Disadvantages

  • Overhead: More complex to manage and can have higher storage overhead.
  • Consistency: Potential for inconsistency due to the flexible schema.

Key-Value Databases

Characteristics

  • Data Structure: Key-value databases store data as simple key-value pairs. Each key is unique and associated with a value, which can be a simple data type (e.g., string, integer) or a more complex object (e.g., JSON, binary data).
  • Simplicity: The data model is straightforward, with no need for a predefined schema. This simplicity allows for high performance and scalability.
  • Querying: Typically, key-value databases do not support complex queries. Data retrieval is done using the key, and the values are opaque to the database.

Examples

  • Redis
  • Amazon DynamoDB
  • Riak

Use Cases

  • Caching: Ideal for applications requiring fast access to frequently accessed data.
  • Session Management: Suitable for storing user session data in web applications.
  • User Preferences: Efficient for storing and retrieving user-specific settings and preferences.

Advantages

  • Performance: High-speed read and write operations due to the simple data model.
  • **Scalab...
middle

middle

Gợi ý câu hỏi phỏng vấn

senior

Explain how would you keep document change history in NoSQL DB?

middle

How does column-oriented NoSQL differ from document-oriented?

junior

Explain difference between scaling horizontally and vertically for databases

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào