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
- > j = { name : "mongo" };
- {"name" : "mongo"}
- > t = { x : 3 };
- { "x" : 3 }
- > db.things.save(j);
- > db.things.save(t);
- > db.things.find();
- { "_id" : ObjectId("4c2209f9f3924d31102bd84a"), "name" : "mongo" }
- { "_id" : ObjectId("4c2209fef3924d31102bd84b"), "x" : 3 }
- >
- > for (var i = 1; i <= 20; i++) db.things.save({x : 4, j : i});
- > db.things.find();
- > var cursor = db.things.find();
- > while (cursor.hasNext()) printjson(cursor.next());
- > db.things.find().forEach(printjson);
- > var cursor = db.things.find();
- > printjson(cursor[4]);
- > var arr = db.things.find().toArray();
- > arr[5];
- > db.things.find({name:"mongo"}).forEach(printjson);
- > db.things.find({x:4}, {j:true}).forEach(printjson);
- > printjson(db.things.findOne({name:"mongo"}));
- > 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.