Mongodb 数据模型概念
2015-10-10 15:30
573 查看
数据模型概念
Opeational Factors and Data Models
lifecycle managementindexing
horizontal scalability
docoument growth
GridFS
GridFS is a specification for storing document that exceeds the BSON-doucument size limit of 16M.数据模型设计
Embedded Data Models
以下情况下,使用embedded 数据模型: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 数据模型: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.
影响因子和数据模型
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
相关文章推荐
- MongoDB 用户认证
- mongodb安装初步
- MongoDB中关于64位整型存储解决方案
- MongoDB(三)
- ES-MongoDB学习1_elasticsearch与mongodb分布式集群环境下数据同步以及遇到的相应问题解答
- 如何对 MongoDB 进行性能优化(五个简单步骤)
- MongoDB安装及用户名密码管理
- MongoDB 性能优化五个简单步骤
- MongoDB 性能优化五个简单步骤
- MongoDB安装
- MongoDB启动
- 如何对 MongoDB 进行性能优化(五个简单步骤)
- MongoDB下载地址
- MongoDB分片故障测试和解决方案
- mongodb nodeJs聚合查询
- 关于Mongodb的全面总结
- MongoDB GridFS 初探
- Windows下Mongodb启动
- MongoDB(3.0.6)查询性能分析
- Mongodb VS Hbase