数据模型概念


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.

数据模型设计


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

转载于:https://www.cnblogs.com/hotbaby/p/4866994.html

Mongodb 数据模型概念相关推荐

  1. 【待完善】MongoDB - 数据模型

    MongoDB - 数据模型 CSDN用户名:jcLee95 附:[概念对比] SQL关系型数据库 MongoDB 数据库 数据库 表 集合(collection) 行 文档(document) 列/ ...

  2. MongoDB基本概念和常用操作(一)

    基本操作 MongoDB将数据存储为一个文档,数据结构由键值(key=>value)对组成 MongoDB文档类似于JSON对象,字段值可以包含其他文档.数组.文档数组 安装管理mongodb环 ...

  3. mongodb 基本概念

    mongodb 基本概念 基于 mongo:4.4.2 database database 数据库 table collection 数据库表/集合 row document 数据记录行/文档 col ...

  4. MongoDB基本概念和安装配置

    基本概念 MongoDB直接存储JSON. 有了NoSQL数据库之后,可以直接在业务层将数据按照指定的结构进行存储. NO SQL NoSQL 1 数据库 数据库 2 表 集合 3 行 文档 4 列 ...

  5. (2) MongoDB基本概念及与关系型数据库的对照

    MongoDB不是关系型数据库,因此也就没有了表,行等概念,但是有一些类似的概念,主要有 数据库(Database),集合(Collection),文档(Document),其中数据库跟关系型数据库的 ...

  6. 《MongoDB入门教程》第03篇 MongoDB基本概念

    本文将会介绍 MongoDB 中的一些基本概念,例如文档.集合.数据库以及命名空间等. 数据格式 在 MongoDB 中,数据使用 JSON 或者 BSON 格式进行处理和存储. JSON JSON ...

  7. web开发——3.数据模型概念

    1-1 主要内容 数据库相关回顾 数据类型的概念 数据类型的定义 数据类型的查询[单表查询] 1-2 课程内容 1. 复习回顾 1.1. 概念整理回顾 a. Django有什么样的开发优势? Djan ...

  8. ElastieSearch安装以及与Mongodb的概念对照关系

    概述 ElasticSearch与JDK之间的兼容关系可以参考[1]  版本 组件 Ubuntu 20.04 ElasticSearch 7.10.1 JDK 1.8.0_131 下载地点见[2],用 ...

  9. mongodb分片概念和原理-实战分片集群

    一.分片 分片是一种跨多台机器分发数据的方法.MongoDB使用分片来支持具有非常大的数据集和高吞吐量操作的部署. 问题: 具有大型数据集或高吞吐量应用程序的数据库系统可能会挑战单个服务器的容量.例如 ...

最新文章

  1. python程序员面试宝典 勘误_《前端面试江湖》勘误合集(二)
  2. 【视频】React redux toolkit创建状态切片
  3. 3分钟学会python_3分钟学会一个Python小技巧
  4. Spring MVC:表单处理卷。 5 –选择,选项,选项标签
  5. extjs5的grid垂直滚动条bug_ExtJS 6.2.1 Classic Grid 滚动条bug解决方案
  6. WEB前端大神之路之基础篇
  7. Educational Codeforces Round 1(D. Igor In the Museum) (BFS+离线访问)
  8. 首批6款5G旗舰手机开卖 最低售价过万!全家桶套餐更酸爽...
  9. 超10000支团队参赛,阿里云首届云原生编程挑战赛完美收官
  10. Atitit 发帖机实现(2)---usrQBN2243 文本解析到对象协议规范
  11. Open3D:DBSCAN(C++)
  12. 【Day 6 of Learning Python 】修改、添加和删除列表元素
  13. 为promise增加abort功能
  14. JAVA读取Excel行数问题
  15. 空指针异常 NullPointException
  16. 万字长文,图文并茂的给你讲清SpringBoot注解,自动装配原理!
  17. 如何重装服务器的系统教程,如何重装服务器系统教程
  18. 浅谈 什么是封装、继承与多态?
  19. @4-1 CCF 2020-06-1 线性分类器
  20. 非全日制计算机专业值得读吗,全日制、非全日制哪个更好?19计算机考研扫盲贴!...

热门文章

  1. Struts2三种传参方式(从jsp页面传到Action)
  2. request获取网页单选框的值
  3. android最全面试题71道题 详解
  4. 统计所有子串写到文件
  5. gin获取路径中的参数
  6. 汇编语言--单步中断
  7. 单链表的的逆置(带头结点)
  8. BigDecimal的四舍五入的RoundingMode 选择
  9. linux中lsof命令详解!
  10. 下列不是c++ 标准数据类型得是?