我应该为多客户端应用程序使用单个还是多个数据库设置? [英] Should I use a single or multiple database setup for a multi-client application?
问题描述
我正在开发一个旨在简化公司工作流程和项目管理的 PHP 应用程序,比如 Basecamp 和 GoPlan.
I am working on a PHP application that intends to ease company workflow and project management, let's say something like Basecamp and GoPlan.
我不确定数据库方面的最佳方法是什么.我应该使用单个数据库并向每个表添加特定于客户的列,还是应该为每个新客户创建一个数据库?一个重要的因素是自动化:我希望创建一个新客户非常简单(也许可以为自己注册).
I am not sure on what the best approach is, database-wise. Should I use a single database and add client-specific columns to each of the tables, or should I create a database for each new client? An important factor is automation: I want it to be dead simple to create a new client (and perhaps opening the possibility to signing up for yourself).
我可以想到使用一个数据库的可能缺点:
Possible cons I can think of using one database:
- 缺乏可扩展性
- 安全问题(尽管错误一开始就不应该存在)
您对此有何看法?您知道上述公司最有可能选择哪种解决方案吗?
What are your thoughts on this? Do you have any ideas what solution the above companies are most likely to have chosen?
推荐答案
我通常将 ClientID 添加到所有表并使用一个数据库.但由于数据库通常难以扩展,我还将允许在不同的数据库实例上为部分或所有客户端运行.
I usually add ClientID to all tables and go with one database. But since the database is usually hard to scale I will also make it possible to run on different database instances for some or all clients.
这样你就可以在一个数据库中拥有一堆小客户端,而在不同的服务器上拥有大客户端.
That way you can have a bunch of small clients in one database and the big ones on separate servers.
不过,可维护性的一个关键因素是您在所有数据库中保持架构相同.在不引入客户端特定模式的情况下管理版本控制会很头疼.
A key factor for maintainability though, is that you keep the schema identical in all databases. There will be headache enough to manage the versioning without introducing client specific schemas.
这篇关于我应该为多客户端应用程序使用单个还是多个数据库设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!