In my previous post I wrote about how to put MongoDB up and running, but previously, MongoDb has a few considerations that you should take into account before going further. To work with NoSQL databases a previous databases skill could be an advantage! Let’s start!
In order to work with MongoDB database (and in general with NoSQL databases), it is neccesary and very important to be concious of this issues:
- It doesn’t exist referential integrity
- There is no sepparate database. It’s a huge document with no normalization, I mean, there are no rules for the design, and it depend on the information you are storing.
- There is a new language to deal with the database, and SQL is not used
- Matrix are a fundamental part to deal with documents
A summary: you can store every thing you want and in the way it fits you the best, with no rules. Flexibility!!
That’s good and bad.
Some times, the existence of rules are necesary, because they (rules) can “guide” users. Skipping these rules has its limitations as well (restrictions) and all this freedom can be a problem if the user doesn’t know perfectly what is he/she doing! I am surprised for all this “freedom”, but that’s the way NoSQL are.
Reading carefully the documentation, it shows up some “rules” you should follow (well, not all freedom as I thought):
- Tables are now called collections.
- Registers on tables are now called documents
- Documentos have no pre-defined structure (freedom)
- The unique keys are strings
- Special characters must be avoided, like ; $ ( but … I thought I can use whatever!!)
- No duplicated keys allowed, because ech document (register) has an unique _ID (generated by MongoDB, … at least, one less thing to worry about!)
Consecuencias of flexibility:
- You lose integrity due to lack of transactions
- You lose index power
- You can create really complex queries, but dealing with more that one collection is also a challenge
In next entrances I show you an example, where you can think about what you can and can’t do, what you should and shouldn’t do, advantages and disadvantagews of using NoSQL databases.
I hope it can be useful for you, and have a nice day!