简体   繁体   English

由两个不同的项目使用相同的数据库

[英]Using the same database by two different projects

In my new work, they have two ASP.net projects. 在我的新作品中,他们有两个ASP.net项目。 Both projects are using the same MS SQL Database. 两个项目都使用相同的MS SQL数据库。 Each project has a different developing team and end users. 每个项目都有一个不同的开发团队和最终用户。 And each project has its own tables, and there are a common tables which both projects reads/writes data, and sometimes they use this common tables to send information to each other. 每个项目都有自己的表,并且有一个公共表,两个项目都可以读取/写入数据,有时它们使用此公共表相互发送信息。 ie one system insert record, the other system update a flag in this record which means 'Yeah I can see it', and update some fields, then the first system catch the data ... etc. 例如,一个系统插入记录,另一个系统更新该记录中的标记,表示“是的,我可以看到它”,并更新一些字段,然后第一个系统捕获数据...等等。

My first question: Is this a good design, what are the disadvantages ? 我的第一个问题:这是一个好的设计,缺点是什么?

In the other hand my opinion to split the database into two databases, one for each project, and make communications between them be through web services. 另一方面,我认为将数据库分为两个数据库,每个项目一个数据库,并通过Web服务在它们之间进行通信。

My second question: which approach is the best practice, and why ? 我的第二个问题:哪种方法是最佳做法,为什么?

I do not think there is any problem of having two different projects sharing a common database. 我认为让两个不同的项目共享一个公共数据库没有任何问题。 Instead of splitting database into two separate databases , I would suggest have single database only and create a third separate WCF project. 我建议不要将数据库分为两个单独的数据库,而应该只使用一个数据库,并创建第三个单独的WCF项目。 This WCF project will have only one purpose that is act as database layer , so all the database queries will be written in that service and asp.net projects will consume it. 这个WCF项目只有一个用途,它充当数据库层,因此所有数据库查询都将写入该服务中,而asp.net项目将使用它。

Advantage of this approach is that all the queries will be centralized and there will not be any duplication of queries.Also in future if any new Module comes in the system like desktop application or Mobile application then there is no need to put large efforts in database queries. 这种方法的优点是所有查询都将被集中化并且不会有任何重复查询。而且将来如果系统中引入了新的模块(例如桌面应用程序或移动应用程序),则无需在数据库中进行大量工作查询。 Same queries can be used in all places, so maintenance will be simpler. 可以在所有地方使用相同的查询,因此维护会更简单。

我认为两个项目共用一个数据库没有任何问题,我的意思是即使在一个项目中,也有太多用户同时更新同一张表。

don't see major drawbacks to the approach. 看不到该方法的主要缺点。 Personally i would prefer database table prefixing like 我个人更喜欢像这样的数据库表前缀

project1_sometbale
project2_sometable
common_sometbale

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

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