《MongoDB in action》2012版 翻译 1.1

A database for the modern web

If you’ve built web applications in recent years, you’ve probably used a relational database as the primary data store, and it probably performed acceptably. Most developers are familiar with SQL, and most of us can appreciate the beauty of a well normalized data model, the necessity of transactions, and the assurances provided by a durable storage engine. And even if we don’t like working with relational databases directly, a host of tools, from administrative consoles to object-relational mappers, helps alleviate any unwieldy complexity. Simply put, the relational database is mature and well known. So when a small but vocal cadre of developers starts advocating alternative data stores, questions about the viability and utility of these new technologies arise. Are these new data stores replacements for relational database systems? Who’s using them in production, and why? What are the trade-offs involved in moving to a nonrelational database? The answers to those questions rest on the answer to this one: why are developers interested in MongoDB?

如果你在近几年建立一个web应用,你很可能使用关系数据库来作为你的首选数据存储(方案),而且它可以合理地运行。大部分开发者熟悉SQL,我们大部分人感激这个优美的规范化了的数据模型,必要的事务和持久化存储引擎提供的保险。即便我们不直接使用关系数据库,大多数的工具,从管理者控制台到面向对象mapper,帮助减少笨拙复杂的工作。Simply put,关系数据库是成熟的(存储方案)且广为人知。所以当一个小群的敢于发声的骨干开发者开始提倡使用一个可替代的数据存储(方案)时,(大家)开始对这个新兴技术的可行性和实用性提出各种问题。这个新的数据存储方案可以替代关系型数据库系统?谁在生产环境中使用到它,为什么?转成非关系型数据库当中的权衡点是什么?所有问题归结为一个:为什么开发者要为MongoDB着迷?

In this chapter

在本章

MongoDB’s history, design goals, and key features
MongoDB的历史,设计目标和主要特性
A brief introduction to the shell and the drivers
简要介绍shell和驱动
Use cases and limitations
用例和限制

        MongoDB is a database management system designed for web applications and internet infrastructure. The data model and persistence strategies are built for high read and write throughput and the ability to scale easily with automatic failover. Whether an application requires just one database node or dozens of them, MongoDB can provide surprisingly good performance. If you’ve experienced difficulties scaling relational databases, this may be great news. But not everyone needs to operate at scale. Maybe all you’ve ever needed is a single database server. Why then would you use MongoDB?

        MongoDB是一个为web应用和基础组件设计的数据库管理系统。数据模型和持久化策略是为高读写吞吐量和故障切换的易扩展性而建立的。无论一个应用需要一个数据库节点还是多个节点,MongoDB都提供不错的令人惊喜的性能。如果你经历过扩展关系型数据库的困难这对你是好消息。但不是每个人都需要扩展操作,也许你要的不过是单个的数据库服务器。那么为什么你要用MongoDB?

        It turns out that MongoDB is immediately attractive, not because of its scaling strategy, but rather because of its intuitive data model. Given that a document-based data model can represent rich, hierarchical data structures, it’s often possible to do without the complicated multi-table joins imposed by relational databases. For example, suppose you’re modeling products for an e-commerce site. With a fully normalized relational data model, the information for any one product might be divided among dozens of tables. If you want to get a product representation from the database shell, we’ll need to write a complicated SQL query full of joins. As a consequence, most developers will need to rely on a secondary piece of software to assemble the data into something meaningful.

        MongoDB被证明是能快速引人入胜并不是因为它的扩展策略,也不是因为它直观的数据模型。假设一个基于文档的数据模型可以展示一个丰富,有层次的数据结构,就很可能不会用到复杂的关系型数据库强制使用的多表结合操作。比如,假设你对电子商务网站的商品建模,用到了完全规范化了的关系型数据库模型,商品的任何属性也许都要分开成多个表。如果你要从一个数据库shell获取一个商品的展示,我们需要写一个复杂的SQL查询来做(表)连接。最后许多开发者都需要依赖第二层的软件来把数据组装成有意义的东西。

        With a document model, by contrast, most of a product’s information can be represented within a single document. When you open the MongoDB JavaScript shell, you can easily get a comprehensible representation of your product with all its information hierarchically organized in a JSON-like structure.1 You can also query for it and manipulate it. MongoDB’s query capabilities are designed specifically for manipulating structured documents, so users switching from relational databases experience a similar level of query power. In addition, most developers now work with objectoriented languages, and they want a data store that better maps to objects. With MongoDB, the object defined in the programming language can be persisted “as is,” removing some of the complexity of object mappers.

        相比用了文档模型,大部分商品信息可表现为单个文档。当你打开MongoDB JavaScript shell,你可以从中获取容易理解的,组织有层次的,类似JSON结构的数据结构来代表你商品,你还可以查询和操作到它。MongoDB的查询功能是特别为操作结构化文档设计的,所以迁移关系型数据库的用户可以体验到近似的查询能力。另外,许多开发者目前还在使用面向对象的语言,他能想要一个能和对象映射的数据存储(结构)。用了MongoDB,编程语言里定义的对象就”像对象那样“被持久化了,(从而)减少了一些复杂的对象映射(过程)。

        If the distinction between a tabular and object representation of data is new to you, then you probably have a lot of questions. Rest assured that by the end of this chapter I’ll have provided a thorough overview of MongoDB’s features and design goals, making it increasingly clear why developers from companies like Geek.net (SourceForge.net) and The New York Times have adopted MongoDB for their projects. We’ll see the history of MongoDB and lead into a tour of the database’s main features. Next, we’ll explore some alternative database solutions and the so-called NoSQL movement,2 explaining how MongoDB fits in. Finally, I’ll describe in general where MongoDB works best and where an alternative data store might be preferable.

        如果你对这些表格化和对象化数据的区别还是陌生的话,那么你会有很多问题。Rest assured that by the end of this chapter I’ll have provided a thorough overview of MongoDB’s features and design goals, making it increasingly clear why developers from companies like Geek.net (SourceForge.net) and The New York Times have adopted MongoDB for their projects. We’ll see the history of MongoDB and lead into a tour of the database’s main features. Next, we’ll explore some alternative database solutions and the so-called NoSQL movement,2 explaining how MongoDB fits in. Finally, I’ll describe in general where MongoDB works best and where an alternative data store might be preferable.

1 JSON is an acronym for JavaScript Object Notation. As we’ll see shortly, JSON structures are comprised of keys

and values, and they can nest arbitrarily deep. They’re analogous to the dictionaries and hash maps of other
programming languages.
2 The umbrella term NoSQL was coined in 2009 to lump together the many nonrelational databases gaining in
popularity at the time.

MongoDB’s key features 5


1.1 Born in the cloud

        The history of MongoDB is brief but worth recounting, for it was born out of a much more ambitious project. In mid-2007, a startup called 10gen began work on a software platform-as-a-service, composed of an application server and a database, that would host web applications and scale them as needed. Like Google’s AppEngine, 10gen’s platform was designed to handle the scaling and management of hardware and software infrastructure automatically, freeing developers to focus solely on their application code. 10gen ultimately discovered that most developers didn’t feel comfortable giving up so much control over their technology stacks, but users did want 10gen’s new database technology. This led 10gen to concentrate its efforts solely on the database that became MongoDB.

        MongoDB的历史虽然简短但需要重述,它诞生于一个雄雄心勃勃的项目。在2007年中,a startup called 10gen began work on a software platform-as-a-service,整合了服务器和数据库,that would host web applications and scale them as needed。想谷歌的AppEngine,10gen平台是为处理扩展性和自动管理软硬基础组件,让开发者从中释放出来更专注与他们的应用代码。10gen最后发现,大多数开发者对放弃他们的技术栈感到不舒服,但是用户想要10gen的新数据库技术。这催成了10gen只在数据库上下功夫,成就了MongoDB。

        With MongoDB’s increasing adoption and production deployments large and small, 10gen continues to sponsor the database’s development as an open source project. The code is publicly available and free to modify and use, subject to the terms of its license. And the community at large is encouraged to file bug reports and submit patches. Still, all of MongoDB’s core developers are either founders or employees of 10gen, and the project’s roadmap continues to be determined by the needs of its user community and the overarching goal of creating a database that combines the best features of relational databases and distributed key-value stores. Thus, 10gen’s business model is not unlike that of other well-known open source companies: support the development of an open source product and provide subscription services to end users.

        (未翻译……)

        This history contains a couple of important ideas. First is that MongoDB was originally developed for a platform that, by definition, required its database to scale gracefully across multiple machines. The second is that MongoDB was designed as a data store for web applications. As we’ll see, MongoDB’s design as a horizontally scalable primary data store sets it apart from other modern database systems.

        这个历史包含了多个重要思想。第一,MongoDB最初是发展为平台,当然,要求它的数据库能跨多台机器扩展。第二,MongoDB是被设计为应用的数据存储方案。正如我们看到,MongoDB作为一个横向可扩展的数据存储设计方案使他从众多其他的现代数据库系统中脱颖而出。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值