5 Mistakes Web Developers Make When Working with MongoDB

downloadMongoDB has founded in 2007, until now it has more than 15 million downloads, it was really tread as cloud server make a prior choice by big data company. And you could build big data very fast by MongoDB, why MongoDB? how it does work? when it has became certain issue to pay attention with? Let’s try to get into the story!!

why MongoDB?

MongoDB is NoSQL database, NoSQL == Not Only SQL, the data structure is combined with key\value, like Json, the data type could be diver compare Relation DataBase, this is very flexible, but flexible could be disaster if not defined, organize data type efficiently!! As follow are couple reasons good for use MongoDB:

  1. For whom are front-end developer, this is much easier to learn then mysql, the MongoDB base language is Javasript & JSON
  2. MongoDB is for big data, you could de-normalize and flatten 6 tables into just 2 tables.
  3. MongoDB is Document based, if you have a tons of a single type of documents, then use Mongo

how it does work?

Install MongoDB

  1. download from https://www.mongodb.com/download-center#community1
  2. De-zip your MongoDB
  3. Create file for database, for example: Data/mydb
  4. open cmd, to MongoDB path, $ mongod –dbpath ../data/mydb
  5. $ mongo , to check if it does work 4
  6. 4
  7. $ show dbs, then here you could see 2 data base are admin, local44
  8. And if you need to show down server, it has to excuse this $ db.shutdownServer(), this is important incase memory not leased, or sync up, destroyed

MongoDB basic usage

This part will show basic usage insert document, remove document, drop collection

1. insert, use cmd call out which db you want to insert, here is employee for example, insert name, account, country. and finally the data show as json:


2. Remove document

db.collection.remove({ condition }), justOne)

justOne: true | false, set if just remove the first data

if you want remove all: db.employee.remove({})

3. Drop document


The rest usage please look at mangoDB tutorial

when it has became certain issue to pay attention with?

there’s some points that you should avoid when use MongoDB

  1. No easy change other DB : When you choice MongoDB, this is not like other RDBMS ———-SQL, all NoSQL has it’s own API, if you had choice it, it won’t be easier to change another DB, example change MongoDB to Couchbase.
  2. Not support ACID: ACID is the basic item of Transaction, but most NoSQL DB not quarante ACID, you need more technical skill to practice this part
  3. Not support JOIN: because NoSQL DB is Non-relational, so it does not support JOIN. use MongoDB, it has to well-orientation Data Model in the first beginning, and you could use index and Aggregation to improve the filter performance.
  4. Document limited: not like RDBMS stock data in row, MongoDB stock data in document, these documents like JSON format. therefore has limited data size, the latest had supported to 16M. So you had to be careful not over to 16M.
  5. Filter search has to define correctly lowercase/uppercase, for example: db.people.find({name: ‘Russell’}) and db.people.find({name: ‘ russell’}) is different. you could filter by regex: db.people.find({name:/Russell/i}), but this will affected the performance.

Voila, this article is very primary presentation for MongoDB, just little mind sharing as first use of mangoDB.


Leave a Reply

Your email address will not be published. Required fields are marked *