Reputation: 20934
I am really looking for some advice on what type of database I should use. If I can give an example APP hopefully you could advise me on what you would consider to be the right approach.
So Lets say I wanted to create a booking system for bed & breakfast's (B&B's). So in a conventional RBDMS I would have Owner Class who have many locations. Each location would have features and would also have an availability calendar. Also each location would have its own bookings and so on.
I love the idea with MongoDB that you could have a location with its own features, bookings etc withing its own record as they only really belong to that location. But where I think this breaks down is for example each booking will have invoices and those records also belong to the people who booked and so on. And would it be a nightmare to build a admin area for such an application.
What would be your take on such a type of application and what type of database would you use.
Look forward to your advise.
Upvotes: 2
Views: 2494
Reputation: 143
I've written several apps that mix and match relational and non-relational databases (MySQL, Mongo, PostGRES, and Riak). It's actually not particularly hard in Rails to do this, and I even wrote a library that creates relations across different types of databases (so your Ripple models can "belongs_to :user" where the user table is in MySQL).
You should always let your needs drive the decisions. Don't waste time shoe-horning your users into Mongo if you are more comfortable keeping them in a relational DB, or trying to push reporting information that may not be normalized into a MySQL table. Analysis of what entities you're storing and the relationships between them will drive your implementations.
Upvotes: 2
Reputation: 11
I wouldn't recommend using MySQL and MongoDB in the same app - much more trouble than it's worth. MongoDB is capable of handling anything a straightforward Rails app like you mention might throw at it, and I think it is much more flexible than MySQL for this kind of application.
Just beware that MongoID and MongoMapper are not exact ports of ActiveRecord - they have similarities but are fundamentally different, due to the fundamentally database behind them. You can create an app that will have relationships like MySQL, so a blog with comments or your booking app will be no problem. Using MongoID, for example, you would want to use the 'references_many, referenced_in' methods rather than 'embeds_many, embedded_in' (http://mongoid.org/docs/associations/).
Upvotes: 1
Reputation: 1637
Sounds like a great application for MongoDB. It seems like the decision is mostly up to you and which database you are most comfortable with.
You should not be afraid to mix and match MongoDB and MySQL in your application. When building your models, you can use ActiveRecord::Base when you want an object to be stored in MySQL and MongoMapper or MongoID when you want an object to be stored in MongoDB. Be careful in how you manage relationships between the two models tho.
Full disclaimer: I work for 10gen. But I would start off using just MongoDB and I think you'll find that it's such a joy to work with that you'll quickly forget about MySQL.
Upvotes: 0