我即将完成构建一个简单的基于订阅的支持票 Web 应用程序。我正在设置授权。但由于这将是我要部署的我自己的 Web 应用程序,所以我对此感到疑惑。
您是否为每个开设的帐户创建一个单独的数据库?
假设您有此支持票 Web 应用程序。您有一个且只有一个帐户所有者。帐户所有者可以设置可以响应支持票的代理。此外,还有一些客户角色可以打开支持票。
如您所见,数据库将包含用户、支持工单等。
最好的方法是什么?
1) 为整个应用程序创建一个数据库?这样,每次有人注册时,所有内容都会与其他门票和用户数据以及其他所有内容一起添加到同一个数据库中,或者...
2) 每次有人注册时,为每个帐户订阅创建一个单独的数据库。
我认为选项 2 可能是出于安全和数据完整性目的的最佳选择。如果是这样,您是如何着手解决这个问题的?
最佳答案
听起来您想要的是 Multi-Tenancy :
Multitenancy refers to a principle in software architecture where a single instance of the software runs on a server, serving multiple client organizations (tenants). Multitenancy is contrasted with a multi-instance architecture where separate software instances (or hardware systems) are set up for different client organizations. With a multitenant architecture, a software application is designed to virtually partition its data and configuration, and each client organization works with a customized virtual application instance. - Wikipedia article on Multitenancy
这篇文章虽然有点过时,但它是我将如何着手去做的总体思路。 Simple Rails Multi-Tenancy .它简洁高效,让您免于编写不需要的代码。
关于ruby-on-rails - Rails 网络应用程序 : do you create a separate database per account opened?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7289368/