首先是启动 mongdb的service ,不启用的话,使用mong shell 连接的现象是:



启动服务端,指定默认的存储的位置即可:

mongod  -- dbpath  F:/store  #数据库默认的存储的位置

在启动一个“黑框框”, 当为客户端来连接启动的这个server

连接到mong server ,并且在service的黑框框中会显示,客户端的连接



下面就是mongo shell 对数据库的操作了

     


表示同一张表中,存储的数据并不是结构化的数据,能够带来很多的好处,但是也可能带来一定的混乱,所以针对
这个,mongdb的数据有一定 的设计的规范,后面可定会有涉及。

在说一下上面的命令,我们的使用命令  db.notify.insert({........});

When you insert the first document, the mongdb will
create both the notify  database and the notify collection
(这里 数据库的名称 和 collection 的名称是一样的)
这里面的collection相当于 sql数据中的表,collection中包含的就是Document,下面是对document的说明:

MongoDB stores data in the form of documents, which are JSON-like
field and value pairs. Documents are analogous to structures in
programming languages that associate keys with values (e.g.
dictionaries, hashes, maps, and associative arrays). Formally, MongoDB
documents are BSON documents. BSON is a binary representation
of JSON with additional type information. In the documents, the
value of a field can be any of the BSON data types, including other
documents, arrays, and arrays of documents.

collection 和 Document 的关系如图所示:MongoDB stores all documents in collections. A
collection is a group of related documents that have a set of shared
common indexes. Collections are analogous to a table in relational
databases.



mongo 的查找: 也就是选择document 从单一的collection里面,就是从一张表中选择记录,符合SQL的思路。



查找的过程 与SQL查找的对应的关系:


find 操作的说明:
  • All queries in MongoDB address a single collection.
  • You can modify the query to impose limits,
    skips, and sort orders.
  • The order of documents returned by a query is not defined unless you
    specify a sort().
  • Operations that modify existing documents (i.e. updates) use the same query
    syntax as queries to select documents to update.
  • In aggregation pipeline, the
    $match pipeline stage provides access to MongoDB
    queries.


  • 索引:提高查找的速度
    db.inventory.find( { type: typeValue } );
    针对Collection inventory 的字段 type 建立索引。
    db.inventory.ensureIndex( { type: 1 } )
    建立索引的语句是:db.collection.ensureIndex(keys, options)
    在这里我们可以通过:db.collection.find({。。。条件。。。}).explain();
    来看到输出的结果,分析读取的效率



    只是简单的描述,感觉和Mysql的explain()比较的像。


    聚合:(aggregation) : In addition to the basic queries, MongoDB provides several data
    aggregation features
    . For example, MongoDB can return counts of the
    number of documents that match a query, or return the number of
    distinct values for a field, or process a collection of documents using
    a versatile stage-based data processing pipeline or map-reduce
    operations.































    mongDB 的使用的更多相关文章

    1. solr+mongo-connector+mongdb+tomcat集成

      话题:solr安装 一.下载solr 本例采用4.10.3版本. Solr所有版本下载地址:http://archive.apache.org/dist/lucene/solr/ 下载完成后,解压的目 ...

    2. [MongDB] 主从架构--官方极力不推荐

      一.缘由: 看着数据库大家庭都有主从模式,想着Mongodb应该也不会落下.但从官网看来,先是早先舍弃了Master-Master模式,现在又在不推荐 Master-Slave模式,这是要标新立异呀. ...

    3. MongDB/C# 杂项

      1.MongDB的时间类型字段输出时为UTC的解决方法:保存到数据库中的数据还是按UTC存的,读出来的就按标识值读 [BsonDateTimeOptions(Kind = DateTimeKind.L ...

    4. HBase与MongDB等NoSQL数据库对照

      HBase概念学习(十)HBase与MongDB等NoSQL数据库对照 转载请注明出处: jiq•钦's technical Blog - 季义钦 一.开篇 淘宝之前使用的存储层架构一直是MySQL数 ...

    5. go语言mongdb管道使用

      原始json: { "listsn": "", "code": "fwq_add", "detail" ...

    6. HBase概念学习(十)HBase与MongDB等NoSQL数据库对照

      转载请注明出处: jiq•钦's technical Blog - 季义钦 一.开篇 淘宝之前使用的存储层架构一直是MySQL数据库,配合以MongDB,Tair等存储. MySQL因为开源,而且生态 ...

    7. mongdb创建自增主键(primary key)的相关讨论 - Jason.Zhi

      根据mongodb官方文档介绍,如果在插入(insert)操作时,没有指定主键id,那么它会自动给插入行自动附上一个主键id.看起来不错,但是详细看看,就会发现这个id值有点复杂. 如下图: mong ...

    8. mongdb Java demo

      接触MONGDB,感觉用起来还挺好.今天做了一个小demo. 一.启动mongdb的服务

    9. springMVC+ mongdb + redis +Jedis 环境搭建

      环境信息: JDK1.7 : Eclipse 4.4.1 ; mongdb + mongVUE:mongDB的安装 redis的下载和安装:window下安装redis maven3.0.5 新建ma ...

    随机推荐

    1. Android 跨应用调用Activity及Service

      如何调用另外一个app应用的activity或者service,本文提供一个验证可行的方法. 调用方法: Intent intent=new Intent("youActionName&qu ...

    2. Android开发艺术探索》读书笔记 (5) 第5章 理解RemoteViews

      第5章 理解RemoteViews 5.1 RemoteViews的应用 (1)RemoteViews表示的是一个view结构,它可以在其他进程中显示.由于它在其他进程中显示,为了能够更新它的界面,R ...

    3. js的new操作符

      1.创建一个空对象,并且 this 变量引用该对象,同时还继承了该函数的原型. 2.属性和方法被加入到 this 引用的对象中. 3.新创建的对象由 this 所引用,并且最后隐式的返回 this . ...

    4. 弹出层easydialog-v2.0

      地址:http://www.lanrentuku.com/down/js/qita-862/ easydialog.css ;;; } .easyDialog_wrapper{ width:320px ...

    5. Android中px、dp、sp的区别

      px: 即像素,1px代表屏幕上一个物理的像素点: px单位不被建议使用,因为同样100px的图片,在不同手机上显示的实际大小可能不同,如下图所示(图片来自android developer guid ...

    6. ie下面兼容性问题的一些总结

      最后一次搞ie兼容性问题,以后都可以不管了0.0 1.浮动兼容性 1.1IE6下的双边距BUG 在IE6下,块元素有浮动和横向margin的时候,最边上元素的横向margin值会被放大成两倍 解决办法 ...

    7. Effective java-泛型思维导图

    8. cer, pfx 创建,并且读取公钥/密钥,加解密 (C#程序实现)

      PKI技术(public key infrastructure)里面,cer文件和pfx文件是很常见的.通常cer文件里面保存着公钥以及用户的一些信息,pfx里面则含有私钥和公钥. 用makecert ...

    9. model 和 view 实现思考

      采用model.view = view 和  view.model=model 进行双向绑定,还有一种方案是采用id号进行绑定,viewmodel的views 和 models 属性存放所有的id 映 ...

    10. jQuery autoResize

      这是一个用jQuery实现的, 自动调整textarea高度, 非常的好!但原作者已经把它的相关描述页面移除了, 这里做个备份吧~但js路径还在:full: http://james.padolsey ...