Basic NoSQL Queries used in MongoDB
NoSQL (‘Not only SQL’) is a programing language for non relational database. It’s a document based that formatted as binary JSON. NoSQL is using like a cloud itself so it suit for large dataset. It isn’t using any server so it’s cheaper than SQL (Structured Query Language).
In SQL, more servers more dataset can be put in so it’s more costly than NoSQL. Servers are using to storage datasets. If developers want to access datasets, they should connected to servers before they do SQL queries . But if datasets needed to processed, SQL need keywords to relation them.
In NoSQL, every collection are automatically connected others. So, if you input data to a column (in NoSQL is called a field), you just only call the field then input the data. It’s difference from SQL that must call the keyword (JOIN) to make relation between columns. But, the bad thing for making relations in NoSQL is you must input manually to every row (in SQL called documents) that needed to be connected.
MongoDB is an open source database that is most popular if you want to learn NoSQL. Even though most of people use it to learn, most of startups are using its. You can learn NoSQL in an easy way in this database. Here’s the basic NoSQL queries in MongoDB:
1.Create a collection
db.createCollection("test")
2. Input
db.test.insert({id:3129847013, name:"Anggi Dwifiani", score:100})
3. Read
db.test.find()
or
db.test.find({name:"Anggi Dwifiani"})
or
db.test.find().limit(5)
4. Update
db.test.update({name:"Anggi Dwifiani"}, {$set:{status:"Pass"}})
5. Delete
db.test.remove({name:"Anggi Dwifiani"})
6. Indexing
db.test.ensureIndex({id:1,score:-1})
I hope can be usefull. :)