简体   繁体   English

管理多个数据库

[英]Managing multiple databases

We have done a project with around 20 tables in SQL Server, and a completed an ASP.NET project. 我们已经完成了一个在SQL Server中包含约20个表的项目,并完成了一个ASP.NET项目。

Recently our client told us about a new parameter called Site . 最近,我们的客户告诉我们一个名为Site的新参数。 As he says there are multiple sites for a project data in Application have to be different for each site. 正如他所说,一个项目中有多个站点,每个站点中的Application数据必须不同。 We are facing some issues now since the application is completely developed we can not update every SQL Server table and every SQL query related to Application to change according to the site parameter now we are discussing to have multiple databases for each site. 由于我们已经完全开发了应用程序,因此我们现在面临一些问题,因为我们正在讨论为每个站点拥有多个数据库,因此无法根据站点参数更新与Application相关的每个SQL Server表和每个SQL查询。

Things get worse because client says there can be around 20 sites per project. 事情变得更糟,因为客户说每个项目可能有大约20个站点。 So for us it'll be very hard to manage 20 databases. 因此,对我们来说,管理20个数据库将非常困难。

Can some one please tell us a appropriate solution for this issue? 有人可以告诉我们适当的解决方案吗?

The solution you have suggested would appear to be the correct one; 您建议的解决方案似乎是正确的。 use a different database per site (note: a database server can host all 20 databases easily depending on the transaction volume). 每个站点使用不同的数据库(请注意:根据交易量,数据库服务器可以轻松托管所有20个数据库)。

Explanation: What you need is to separate the data per site; 说明:您需要的是将每个站点的数据分开。 this can either be done by adding a site identifier to the tabular data or by making sure sites do not share a datastore; 可以通过在表格数据中添加站点标识符或确保站点不共享数据存储区来完成; the latter is in this case the easiest and most cost effective solution. 在这种情况下,后者是最简单,最具成本效益的解决方案。

Note that "maintaining a database" is not as hard as you make it sound; 请注意,“维护数据库”并不像听起来那么难。 in my opinion the volume of the data and transactions to manage and the number of manual corrections to make are the key factors in cost of maintenance... 我认为要管理的数据和交易量以及要进行的手动更正次数是维护成本的关键因素...

I've been down this road in the past before and what we did was created a Site table, and then the objects that a site owned, we added a foreign key relationship back to the Site table. 过去,我一直走这条路,然后创建了一个Site表,然后创建了一个站点所拥有的对象,然后向该Site表中添加了一个外键关系。

In our case we only had three or four objects that a site owned, so we only had to modify 4 tables. 在我们的例子中,一个站点只有三个或四个对象,因此我们只需要修改4个表。 Then the relationship from there down would still work and no modifications would be needed. 这样,从现在开始的关系仍然可以工作,不需要修改。

I would not go the route of a database per site, it will become a maintenance nightmare if you have to make database changes in the future or if you want to pull reports across the system as a whole 我不会在每个站点使用数据库路由,如果您将来必须进行数据库更改或者要在整个系统中提取报表,它将成为维护的噩梦

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM