Procedure of MongoDB and Its C # driver

Source: Internet
Author: User

1: Brief Introduction

MongoDB is a distributed document database that supports a master-slave structure similar to a relational database. It stores documents in binary Json format, without locks, transactions, and indexes.

2: Installation Steps

Step 1: Download the Assembly http://www.mongodb.org/downloads

Part 2: decompress and extract the relevant bin directory to this arbitrary choice under C: \ Mongo), and create the db folder under this directory.

Part 3: Open the CMD window, go to the C: \ Mongo \ bindirectory, and run mongod.exe -- dbpath = "c: \ Mongo \ db"

Step 4: open another window to keep the previous window closed and run cmd.exe. In this window, you can execute simple commands, which are listed below

 
 
  1. > j = { name : "mongo" };  
  2. {"name" : "mongo"}  
  3. > t = { x : 3 };  
  4. { "x" : 3  }  
  5. > db.things.save(j);  
  6. > db.things.save(t);  
  7. > db.things.find();  
  8. { "_id" : ObjectId("4c2209f9f3924d31102bd84a"), "name" : "mongo" }  
  9. { "_id" : ObjectId("4c2209fef3924d31102bd84b"), "x" : 3 }  
  10. >  
  11. > for (var i = 1; i <= 20; i++) db.things.save({x : 4, j : i});  
  12. > db.things.find();  
  13. > var cursor = db.things.find();  
  14. > while (cursor.hasNext()) printjson(cursor.next());  
  15. > db.things.find().forEach(printjson);  
  16. > var cursor = db.things.find();  
  17. > printjson(cursor[4]);  
  18. > var arr = db.things.find().toArray();  
  19. > arr[5];  
  20. > db.things.find({name:"mongo"}).forEach(printjson);  
  21. > db.things.find({x:4}, {j:true}).forEach(printjson);  
  22. > printjson(db.things.findOne({name:"mongo"}));  
  23. > db.things.find().limit(3); 

3: C # driver

The following describes several C # drivers.

Article 1: mongodb-csharp Project address: http://github.com/samus/mongodb-csharp

Brief Introduction: the driver is a full-featured driver with fast update. It has been applied to the project and performs very well. At present, their team is working on expansion of connection management functions, such as automatic reconnection and connection pool.

Article 2: mongodb-net project address: http://code.google.com/p/mongodb-net/

Brief Introduction: The development is still in progress, and some features are not yet implemented

Article 3 MongoDB. Emitter Project address: http://bitbucket.org/gwbasic/mongodb.emitter/

Brief Introduction: supports strong types

Section 4: CSMongo Project address: http://somewebguy.wordpress.com/2010/02/21/building-a-mongo-driver-part-1/

Brief Introduction: some functions are implemented and there is no downloadable code. But you can read his blog to understand this idea.

Article 5: simple-mongodb Project address: http://code.google.com/p/simple-mongodb/

Brief Introduction: source code is not provided, with JSon as the core.

The last one is the enhancement to the first one in some places, address http://deserialized.com/convert-csharp-classes-to-and-from-mongodb-documents-automatically-using-net-reflection

Article 6 NoRM project address: http://github.com/atheken/NoRM

Description: The first type is enhanced. Strong types are supported.

Additional reading

 

MongoDB Logo

Mongo is a high-performance, open-source, and non-pattern document-based database. It can be used in many scenarios to replace traditional relational databases or key/value storage methods. Mongo is developed using C ++ and provides the following functions:

◆ Set-oriented storage: Suitable for storing objects and JSON data.

◆ Dynamic query: Mongo supports a wide range of Query expressions. Query commands use JSON tags to easily query embedded objects and arrays in a document.

◆ Complete indexing support: Includes embedded object and array of documents. The Query Optimizer of Mongo analyzes the query expression and generates an efficient query plan.

◆ Query monitoring: Mongo provides a monitoring tool to analyze the performance of database operations.

◆ Replication and automatic failover: The Mongo Database supports data replication between servers and master-slave mode and mutual replication between servers. The primary objective of replication is to provide redundancy and automatic failover.

◆ Efficient traditional storage: supports binary data and large objects such as photos or images ).

◆ Automatic sharding to support cloud-level scalability in the early alpha stage): the automatic sharding function supports horizontal database clusters and allows you to dynamically add additional machines.

The primary goal of MongoDB is to build a bridge between high performance and high scalability in the key/value storage mode and the rich functions of traditional RDBMS systems. Mongo is applicable to the following scenarios:

◆ Website data: Mongo is ideal for real-time insertion, update, and query, as well as the replication and high scalability required for real-time website data storage.

◆ Cache: because of its high performance, Mongo is also suitable for serving as the cache layer of information infrastructure. After the system is restarted, the persistent cache layer established by Mongo can avoid data source overload at the lower layer.

◆ Large-sized and low-value data: traditional relational databases may be expensive to store some data. Previously, programmers often choose traditional files for storage.

◆ High scalability: Mongo is ideal for databases consisting of dozens or hundreds of servers. The Mongo roadmap contains built-in support for the MapReduce engine.

◆ Used for storage of objects and JSON data: The BSON data format of Mongo is very suitable for storing and querying document-based data.

Naturally, there are some restrictions on the use of MongoDB, for example, it is not suitable:

◆ Highly transactional systems: such as banking or accounting systems. Traditional relational databases are still more suitable for applications that require a large number of atomic complex transactions.

◆ Traditional business intelligence applications: BI databases for specific problems will produce highly optimized query methods. For such applications, data warehouse may be a more appropriate choice.

◆ SQL Problems

MongoDB supports OS X, Linux, Windows, and other operating systems. It also provides drivers for Python, PHP, Ruby, Java, and C ++. The community also provides Erlang and.. NET.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.