为每个客户端使用单个数据库有什么好处? [英] What are the advantages of using a single database for EACH client?

查看:23
本文介绍了为每个客户端使用单个数据库有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为多个客户端设计的以数据库为中心的应用程序中,我一直认为对所有客户端使用单个数据库更好" - 将记录与适当的索引和键相关联.在听 Stack Overflow 播客时,我听到 Joel 提到 FogBugz 每个客户端使用一个数据库(所以如果有 1000 个客户端,就会有 1000 个数据库).使用这种架构有什么好处?

In a database-centric application that is designed for multiple clients, I've always thought it was "better" to use a single database for ALL clients - associating records with proper indexes and keys. In listening to the Stack Overflow podcast, I heard Joel mention that FogBugz uses one database per client (so if there were 1000 clients, there would be 1000 databases). What are the advantages of using this architecture?

我知道对于某些项目,客户需要直接访问他们的所有数据 - 在这样的应用程序中,很明显每个客户都需要自己的数据库.但是,对于客户端不需要直接访问数据库的项目,一个客户端使用一个数据库有什么好处吗?似乎在灵活性方面,使用带有单个表副本的单个数据库要简单得多.添加新功能更轻松,创建报告更轻松,管理更轻松.

I understand that for some projects, clients need direct access to all of their data - in such an application, it's obvious that each client needs their own database. However, for projects where a client does not need to access the database directly, are there any advantages to using one database per client? It seems that in terms of flexibility, it's much simpler to use a single database with a single copy of the tables. It's easier to add new features, it's easier to create reports, and it's just easier to manage.

我对所有客户的一个数据库"方法非常有信心,直到我听到 Joel(一位经验丰富的开发人员)提到他的软件使用了不同的方法——我对他的决定有点困惑......

I was pretty confident in the "one database for all clients" method until I heard Joel (an experienced developer) mention that his software uses a different approach -- and I'm a little confused with his decision...

我听说有人说数据库因大量记录而变慢,但任何具有某些优点的关系数据库都不会出现这个问题 - 特别是如果使用了正确的索引和键.

I've heard people cite that databases slow down with a large number of records, but any relational database with some merit isn't going to have that problem - especially if proper indexes and keys are used.

非常感谢任何输入!

推荐答案

假设将所有客户端存储在一个数据库中没有扩展惩罚;对于大多数人来说,以及配置良好的数据库/查询,现在这将是相当正确的.如果您不是这些人中的一员,那么单一数据库的好处是显而易见的.

Assume there's no scaling penalty for storing all the clients in one database; for most people, and well configured databases/queries, this will be fairly true these days. If you're not one of these people, well, then the benefit of a single database is obvious.

在这种情况下,好处来自每个客户端的封装.从代码的角度来看,每个客户端都是孤立存在的——不可能出现数据库更新可能覆盖、损坏、检索或更改属于另一个客户端的数据的情况.这也简化了模型,因为您无需考虑记录可能属于另一个客户端的事实.

In this situation, benefits come from the encapsulation of each client. From the code perspective, each client exists in isolation - there is no possible situation in which a database update might overwrite, corrupt, retrieve or alter data belonging to another client. This also simplifies the model, as you don't need to ever consider the fact that records might belong to another client.

您还可以获得可分离性的好处 - 提取与给定客户端关联的数据并将它们移动到不同的服务器是微不足道的.或者在调用我们删除了一些关键数据!"时使用内置数据库机制恢复该客户端的备份.

You also get benefits of separability - it's trivial to pull out the data associated with a given client ,and move them to a different server. Or restore a backup of that client when the call up to say "We've deleted some key data!", using the builtin database mechanisms.

您可以获得轻松且免费的服务器移动性 - 如果您超出一台数据库服务器的规模,您可以在另一台服务器上托管新客户端.如果它们都在一个数据库中,您要么需要更强大的硬件,要么在多台机器上运行数据库.

You get easy and free server mobility - if you outscale one database server, you can just host new clients on another server. If they were all in one database, you'd need to either get beefier hardware, or run the database over multiple machines.

您可以轻松进行版本控制 - 如果一个客户想要保留软件版本 1.0,而另一个想要 2.0,其中 1.0 和 2.0 使用不同的数据库架构,没有问题 - 您可以迁移一个而无需将它们从一个数据库中拉出.

You get easy versioning - if one client wants to stay on software version 1.0, and another wants 2.0, where 1.0 and 2.0 use different database schemas, there's no problem - you can migrate one without having to pull them out of one database.

我想我还能想到几十个.但总而言之,关键概念是简单".该产品管理一个客户端,因此管理一个数据库.但数据库还包含其他客户端"问题从来没有任何复杂性.它符合用户的心理模型,他们单独存在.能够一次性对所有客户进行轻松报告等优势是微乎其微的 - 您多久需要一份关于整个世界的报告,而不仅仅是一个客户?

I can think of a few dozen more, I guess. But all in all, the key concept is "simplicity". The product manages one client, and thus one database. There is never any complexity from the "But the database also contains other clients" issue. It fits the mental model of the user, where they exist alone. Advantages like being able to doing easy reporting on all clients at once, are minimal - how often do you want a report on the whole world, rather than just one client?

这篇关于为每个客户端使用单个数据库有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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