Rails应用程序中的MongoDB或MySQL或两者 [英] MongoDB or MySQL or Both in a Rails App

查看:82
本文介绍了Rails应用程序中的MongoDB或MySQL或两者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的在寻找有关应该使用哪种数据库类型的建议.如果我希望举一个示例APP,希望您能向我建议您认为正确的方法.

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.

所以让我说我想创建一个床位预订系统.早餐(早餐和早餐).因此,在常规的RBDMS中,我将拥有拥有许多位置的所有者类.每个位置都将具有功能,并且还将具有可用性日历.此外,每个地点都会有自己的预订,依此类推.

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.

我喜欢MongoDB的想法,即您可以拥有一个具有其自身功能,预订等并具有自己记录的位置,因为它们仅真正属于该位置.但是我认为发生这种情况的地方是,例如每个预订都会有发票,而这些记录也属于预订的人等等.为这样的应用程序建立一个管理区域将是一场噩梦.

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.

期待您的建议.

推荐答案

我编写了一些混合并匹配关系数据库和非关系数据库(MySQL,Mongo,PostGRES和Riak)的应用程序.实际上,在Rails中做到这一点并不是特别困难,我什至编写了一个库来创建跨不同类型数据库的关系(因此您的Ripple模型可以属于用户表",而在MySQL中是用户表).

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).

您应该始终让您的需求来驱动决策.如果您更愿意将用户保留在关系数据库中,或者尝试将可能无法规范化的报告信息推送到MySQL表中,请不要浪费您的时间让您的用户进入Mongo.分析您要存储的实体及其之间的关系将推动您的实现.

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.

这篇关于Rails应用程序中的MongoDB或MySQL或两者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆