nosql
What is NoSQL, how does it work, and what benefits does it provide? [closed]
There is no such thing as NoSQL! NoSQL is a buzzword. For decades, when people were talking about databases, they meant relational databases. And when people were talking about relational databases, they meant those you control with Edgar F. Codd’s Structured Query Language. Storing data in some other way? Madness! Anything else is just flatfiles. … Read more
Is there a query language for JSON?
Sure, how about: JsonPath. Json Query They all seem to be a bit work in progress, but work to some degree. They are also similar to XPath and XQuery conceptually; even though XML and JSON have different conceptual models (hierarchic vs object/struct). EDIT Sep-2015: Actually there is now JSON Pointer standard that allows very simple … Read more
Add new field to every document in a MongoDB collection
Same as the updating existing collection field, $set will add a new fields if the specified field does not exist. Check out this example: > db.foo.find() > db.foo.insert({“test”:”a”}) > db.foo.find() { “_id” : ObjectId(“4e93037bbf6f1dd3a0a9541a”), “test” : “a” } > item = db.foo.findOne() { “_id” : ObjectId(“4e93037bbf6f1dd3a0a9541a”), “test” : “a” } > db.foo.update({“_id” :ObjectId(“4e93037bbf6f1dd3a0a9541a”) },{$set : … Read more
MongoDB dot (.) in key name
MongoDB doesn’t support keys with a dot in them so you’re going to have to preprocess your JSON file to remove/replace them before importing it or you’ll be setting yourself up for all sorts of problems. There isn’t a standard workaround to this issue, the best approach is too dependent upon the specifics of the … Read more
Possibility of duplicate Mongo ObjectId’s being generated in two different collections?
Short Answer Just to add a direct response to your initial question: YES, if you use BSON Object ID generation, then for most drivers the IDs are almost certainly going to be unique across collections. See below for what “almost certainly” means. Long Answer The BSON Object ID’s generated by Mongo DB drivers are highly … Read more
MongoDB: How to update multiple documents with a single command?
Multi update was added recently, so is only available in the development releases (1.1.3). From the shell you do a multi update by passing true as the fourth argument to update(), where the the third argument is the upsert argument: db.test.update({foo: “bar”}, {$set: {test: “success!”}}, false, true); For versions of mongodb 2.2+ you need to … Read more
Update field in exact element array in MongoDB
You need to make use of 2 concepts: mongodb’s positional operator and simply using the numeric index for the entry you want to update. The positional operator allows you to use a condition like this: {“heroes.nickname”: “test”} and then reference the found array entry like so: {“heroes.$ // <- the dollar represents the first matching … Read more
MySQL and NoSQL: Help me to choose the right one
You should read the following and learn a little bit about the advantages of a well designed innodb table and how best to use clustered indexes – only available with innodb ! http://dev.mysql.com/doc/refman/5.0/en/innodb-index-types.html http://www.xaprb.com/blog/2006/07/04/how-to-exploit-mysql-index-optimizations/ then design your system something along the lines of the following simplified example: Example schema (simplified) The important features are that … Read more