Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB as the primary database?

I have read a lot of the MongoDB.

I like all the features it provides, but I wonder if it's possible to have it as the only database for my application, including storing sensitive information.

I know that it compromises the durability part in ACID but I will as a solution have 1 master and 2 slaves in different locations.

If I do that, is it possible to use it as the primary database, storing everything?

UPDATE:

Lets put it this way.

I really need a document storage rather than traditional dbms for be able to create my flexible application. But is MongoDB reliable enough to store customer sensitive information if I have multiple database replications and master-slave? Cause as far as I know one major downside is that it compromises the D in ACID. So I solve it with multiple databases.

Now there is not major problems such as lost of data issues?

And someone told me that with MongoDB a customer could be billed twice. Could someone enlighten this?

like image 524
never_had_a_name Avatar asked Sep 18 '10 03:09

never_had_a_name


2 Answers

Yes, MongoDB can work as an application's only data store. Use replication and make sure you know about safe writes and w.

And someone told me that with MongoDB a customer could be billed twice. Could someone enlighten this?

I'm guessing whoever told you that was talking about eventual consistency. Some NoSQL databases are eventually consistent, meaning that you could have conflicting writes. MongoDB is not, though, it is strongly consistent (just like a relational database).

like image 60
kristina Avatar answered Nov 15 '22 06:11

kristina


Your application being flexible or not has absoutely nothing to do with wether you use "nosql", a "document db" or a proper RDBMS. Nobody using your application will care either way.

If you need flexibility while coding, you should research into frameworks, like ActiveRecord for Ruby, which can make DB-interfacing much more simple, generic and powerful. At that level, you can gain alot more than just changing the DB, and you can even become DB-agnostic, meaning you can change DB without changing any code. Indeed, I have found ActiveRecord to boost my productivity many many fold by alleviating me from tedious and error-prone "code intermixed with SQL".

Indeed, if you feel you need a schemaless database, for critical data, you are doing something wrong. You are putting your own convenience over critical needs of the projects, or in ignorance thinking you won't get into problems later. Sooner or later, lack of consistency will bite your ass, hard!

I feel you are hesistant towards RDBMS because you are not really that comfortable with all the jargons, syntax and sound CS principles.

Believe me, if you're going to create an application of any value, you are hundred times better learning SQL, ACID and good database-principles in the first place. Just read up on the basics, and build your knowledge from wherever you are now. It's the same for each and every one of us, it takes time, but you learn to do things right from the start.

Low-level tools like MongoDB and equivalent just provide you with infinitely more ammunition to shoot yourself in the foot with. They make it seem easy. In reality however, they leave the hard work for you, the coder, to deal with, while an RDBMS will handle more of the cruft for you once you grok the basics.

Why use computers at all, if you want more work, you can just go back to paper. Design will be a breeze, and implementation can be super-quick. Done. Except it won't be right of course.

In the real world, we can't afford to ignore consistency, database design and many more sound CS principles. Which is why it's a great idea to study them in the first place, and keep learning more and more.

Don't buy into the hype. You ask question about MongoDB here, but include that you really need its features. With 25 years of computer experience, I simply don't buy it. If you think creatively, an RDBMS can be made to do whatever you want it to, or a framework can be utilized to save you from errors and wasted time.

Crafting ACID properties onto MongoDB seems like more work to me, and by experience, sounds like an excercise in futility, rather than using what is already designed to suit such purposes.

like image 45
Fred Avatar answered Nov 15 '22 06:11

Fred