MongoDB:The Definitive Guide CHAPTER 1 Introduction

MongoDB is a powerful, flexible, and scalable data store. It combines the ability to scale out with many of the most useful features of relational databases, such as secondary indexes, range queries, and sorting. MongoDB is also incredibly featureful: it has tons of useful features such as built-in support for MapReduce-style aggregation and geospatial indexes.

There is no point in creating a great technology if it’s impossible to work with, so a lot of effort has been put into making MongoDB easy to get started with and a pleasure to use. MongoDB has a developer-friendly data model, administrator-friendly configuration options, and natural-feeling language APIs presented by drivers and the database shell. MongoDB tries to get out of your way, letting you program instead of worrying about storing data.

A Rich Data Model

MongoDB is a document-oriented database, not a relational one. The primary reason for moving away from the relational model is to make scaling out easier, but there are some other advantages as well.

The basic idea is to replace the concept of a “row” with a more flexible model, the “document.” By allowing embedded documents and arrays, the document-oriented approach makes it possible to represent complex hierarchical relationships with a single record. This fits very naturally into the way developers in modern object-oriented languages think about their data.

MongoDB is also schema-free: a document’s keys are not predefined or fixed in any way. Without a schema to change, massive data migrations are usually unnecessary.New or missing keys can be dealt with at the application level, instead of forcing all data to have the same shape. This gives developers a lot of flexibility in how they work with evolving data models.

Easy Scaling

Data set sizes for applications are growing at an incredible pace. Advances in sensor technology, increases in available bandwidth, and the popularity of handheld devices that can be connected to the Internet have created an environment where even small-scale applications need to store more data than many databases were meant to handle.A terabyte of data, once an unheard-of amount of information, is now commonplace.

As the amount of data that developers need to store grows, developers face a difficult decision: how should they scale their databases? Scaling a database comes down to the choice between scaling up (getting a bigger machine) or scaling out (partitioning data across more machines). Scaling up is often the path of least resistance, but it has draw-backs: large machines are often very expensive, and eventually a physical limit is reached where a more powerful machine cannot be purchased at any cost. For the type of large web application that most people aspire to build, it is either impossible or not cost-effective to run off of one machine. Alternatively, it is both extensible and economical to scale out: to add storage space or increase performance, you can buy another commodity server and add it to your cluster.

MongoDB was designed from the beginning to scale out. Its document-oriented data model allows it to automatically split up data across multiple servers. It can balance data and load across a cluster, redistributing documents automatically. This allows developers to focus on programming the application, not scaling it. When they need more capacity, they can just add new machines to the cluster and let the database figure out how to organize everything.

Tons of Features…

It’s difficult to quantify what a feature is: anything above and beyond what a relational database provides? Memcached? Other document-oriented databases? However, no matter what the baseline is, MongoDB has some really nice, unique tools that are not (all) present in any other solution.

Indexing
MongoDB supports generic secondary indexes, allowing a variety of fast queries,and provides unique, compound, and geospatial indexing capabilities as well.

Stored JavaScript
Instead of stored procedures, developers can store and use JavaScript functions and values on the server side.
Aggregation
MongoDB supports MapReduce and other aggregation tools.
Fixed-size collections
Capped collections are fixed in size and are useful for certain types of data, such as logs.
File storage
MongoDB supports an easy-to-use protocol for storing large files and file metadata.

Some features common to relational databases are not present in MongoDB, notably joins and complex multirow transactions. These are architectural decisions to allow for scalability, because both of those features are difficult to provide efficiently in a distributed system.

…Without Sacrificing Speed

Incredible performance is a major goal for MongoDB and has shaped many design decisions. MongoDB uses a binary wire protocol as the primary mode of interaction with the server (as opposed to a protocol with more overhead, like HTTP/REST). It adds dynamic padding to documents and preallocates data files to trade extra space usage for consistent performance. It uses memory-mapped files in the default storage engine, which pushes the responsibility for memory management to the operating system. It also features a dynamic query optimizer that “remembers” the fastest way to perform a query. In short, almost every aspect of MongoDB was designed to maintain high performance.

Although MongoDB is powerful and attempts to keep many features from relational systems, it is not intended to do everything that a relational database does. Whenever possible, the database server offloads processing and logic to the client side (handled either by the drivers or by a user’s application code). Maintaining this streamlined(流线型的;改进的) design is one of the reasons MongoDB can achieve such high performance.

Simple Administration

MongoDB tries to simplify database administration by making servers administrate themselves as much as possible. Aside from starting the database server, very little administration is necessary. If a master server goes down, MongoDB can automatically failover(失效备援) to a backup slave and promote the slave to a master. In a distributed environment, the cluster needs to be told only that a new node exists to automatically integrate and configure it.

MongoDB’s administration philosophy(哲学;哲理;人生观) is that the server should handle as much of the configuration as possible automatically, allowing (but not requiring) users to tweak their setups if needed.

But Wait, That’s Not All…

Throughout the course of the book, we will take the time to note the reasoning or motivation behind particular decisions made in the development of MongoDB.Through those notes we hope to share the philosophy behind MongoDB. The best way to summarize the MongoDB project, however, is through its main focus—to create a full-featured data store that is scalable, flexible, and fast.

时间: 2024-10-12 12:45:28

MongoDB:The Definitive Guide CHAPTER 1 Introduction的相关文章

MongoDB:The Definitive Guide CHAPTER 2 Getting Started

MongoDB is very powerful, but it is still easy to get started with. In this chapter we’ll introduce some of the basic concepts of MongoDB: • A document is the basic unit of data for MongoDB, roughly equivalent to a row in a relational database manage

THE DEFINITIVE GUIDE TO DEBUGGING JAVASCRIPT

FIGURING OUT WHERE THE ERROR COULD BE READ THE CODE USING THE CONSOLE THE CHROME DEV TOOLS THE DEBUGGER BREAKPOINTS SCOPE WATCH VARIABLES AND EXPRESSIONS RESUME THE EXECUTION EDIT SCRIPTS INSPECT THE CALL STACK BLACKBOX SCRIPTS Often times you work w

MONGODB的内部构造 FROM 《MONGODB THE DEFINITIVE GUIDE》

今天下载了<MongoDB The Definitive Guide>电子版,浏览了里面的内容,还是挺丰富的.是官网文档实际应用方面的一个补充.和官方文档类似,介绍MongoDB的内部原理是少之又少,只有在附录的一个章节中介绍了相关内容. 对于大多数的MongoDB的用户来说,MongoDB就像是一个大黑盒,但是如果你能够了解到MongoDB内部一些构造的话,将有利于你更好地理解和使用MongoDB. BSON 在MongoDB中,文档是对数据的抽象,它被使用在Client端和Server端的

WebLogic: The Definitive Guide examined WebLogic&#39;s security mechanisms--reference

reference from: http://www.onjava.com/pub/a/onjava/excerpt/weblogic_chap17/index1.html?page=1 .................................................................................................................................................... http://

Logback手册 Chapter 1: Introduction

翻译不周,多多包含 ---------------------------------------------------------------------------------------分割线-------------------------------------------------------------------- Logback是继承自流行的log4j项目.作者经验丰富,作为积累了十年日志系统设计的经验的结晶,Logback既快又比现有的日志系统短小精悍.更夸张的说,Log

JVM Specification 9th Edition (2) Chapter 1. Introduction

Chapter 1. Introduction 翻译太累了,我就这样的看英文吧. 内容列表 1.1. A Bit of History 1.2. The Java Virtual Machine 1.3. Organization of the Specification 1.4. Notation 1.5. Feedback 1.1. A Bit of History The Java? programming language is a general-purpose, concurrent

MongoDB:如何正常关闭服务(转)

原文链接:MongoDB:关闭服务 MongoDB 提供几种关闭服务的命令,具体为以下: 一 使用 Crtl+C 关闭  [[email protected] data]$ mongod --dbpath=/database/mongodb/data/ --logpath=/var/applog/mongo_log/mongo.log --logappend --port=27017 --journal > start_mongo.log 2>&1光标:键入 Crtl+C 关闭 备注:

MongoDB:数据模型介绍

在MongoDB的数据有灵活的模式.不像SQL数据库,(SQL数据库)要求你必须在插入数据之前决定和声明一个表的模式,MongoDB的集合不强制文档的结构.这个灵活性有利于文档到实体或对象的映射.每个文档可以匹配所要表示实体的数据字段,即使数据的变化很显著.但在实际操作中,一个集合的文档共享一个相似的结构. 数据模型的关键挑战在于平衡应用的需要,数据库引擎的性能和数据存取模式.当设计数据模型时,要考虑数据在应用里的使用情况(如,查询.更新和处理数据),以及数据本身的内在结构. 文档结构 在为Mo

MongoDB:更改数据库位置(Windows)

MongoDB在Windows中默认的数据库目录是c:\data.如果在没有该目录的情况下,直接运行mongod.exe,就会报如下错误: 在某些情况下,我们并不想把mongoDB的数据库放在c盘,这时候有两种方法可以切换数据库目录. 1. 命令方式 首先创建数据库目录,例如d:\data.然后运行命令 mongod –dbpath d:\data 2. 配置文件方式 在任意位置创建一个配置文件,例如c:\mongodb\conf的目录下创建一个名为master.cfg的文件,内容为dbpath