日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Mongodb 数据模型概念

發(fā)布時間:2025/5/22 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Mongodb 数据模型概念 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

數(shù)據(jù)模型概念


Opeational Factors and Data Models

  • lifecycle management
  • indexing
  • horizontal scalability
  • docoument growth

GridFS

??? GridFS is a specification for storing document that exceeds the BSON-doucument size limit of 16M.

?

數(shù)據(jù)模型設(shè)計


Embedded Data Models

以下情況下,使用embedded 數(shù)據(jù)模型:

  • you have “contains”relationships? between entities.? One-to-One relationship
  • you have one-to-many relationships between entities. In these relationships the “many” or child documents always appear with or are viewed in the context of the “one”or parent documents. One-to-Many relationships

?

Normalized Data Models

以下情況下,使用normalized 數(shù)據(jù)模型:

  • when embedding would result in duplicaton of data but would not provide sufficient read performance adavantages to outweigh the implications of the duplication.
  • to represent more complex many-to-many relationships.
  • to model large hierarchical data sets.

?

影響因子和數(shù)據(jù)模型

Document Growth

For MMAPv1, if the document size exceeds the allocated space for that document, MongoDB will reallocate the document on disk.

Atomicity

In MongoDB, operations are atomic at the document level.

Sharding

MongoDB uses sharding to provide horizontal scaling.These clusters support deloyments with large data sets and high-throughput operations.

To distribute data and application traffic in a sharded collection, MongoDB uses the shard key.

Indexes

Uses indexes to improve performance for common queries. Build indexes on fields that apper offten in queries and fro all operations that return sorted results.

The negative influence of creating indexes:

  • Each index requires at lease 8KB of data space.
  • Adding an index has some negative performance impact for writing operations. For collections with high write-to-read ratio, indexes are expensive since each insert must also update any indexes.
  • Each index consumes disk space and memory. This usage can be significant and should be tracked for capacity planning, especially for concerns over working set size.

Large Number of Collections

Data Lifecycle Management

The Time to Live or TTL feature of collections expires document after a period of time. Consider using the TTL feature if your application requires some data to persist in the database for limited period of time.

If your application only use recently inserted documents, consider Capped Collections. It provide FIFO management of inserted documents.

GridFS

GridFS is specification for storing and retrieving files that excced the BSON-document size limit of 16M.

Instead of storing a file in a single document, GridFS divides a file into parts, or chunks and stores each of those chunks as separate document. By default? GridFS limits chunk size to 155k. GridFS uses two collections to store files. One collection stores the file chunks, and the other stores file metadata.

Implement GridFS

GridFS Collections

GridFS Index

Additional Resources

轉(zhuǎn)載于:https://www.cnblogs.com/hotbaby/p/4866994.html

總結(jié)

以上是生活随笔為你收集整理的Mongodb 数据模型概念的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。