我应该为每个Web应用程序创建特殊的模式,还是将其全部放在一个模式中? [英] Should I create special schema for each web application or put it all in a single schema?

查看:120
本文介绍了我应该为每个Web应用程序创建特殊的模式,还是将其全部放在一个模式中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天,我正在设计一个Web应用程序的MySQL数据库,它有两部分:

Good day, I'm designing MySQL database for a web application which has two parts:


  1. 第一部分是成员系统维护国家/组织/子组织/用户层次结构,服务参数和用户角色。

  2. 第二部分是用于管理这些订单中的订单和任务的Web应用程序。它将使用成员系统对用户进行身份验证,并获取为此webapp配置的角色和服务参数。

  3. 将来会有另一个应用程序(以后可能还有一些)用于电子拍卖将使用相同的成员系统对用户进行身份验证,并获得电子拍卖的角色和服务参数。

所有这些webapps通常由相同的组织/用户使用。为每个应用程序创建单独的模式并在它们之间创建外键是个好主意?例如,用于管理订单的webapp将具有自己的模式,成员系统将拥有自己的模式,并且排序webapp的表将引用成员模式中的表(因为订单具有owner = organization,user等)。后来的拍卖webapp将在成员系统模式中拥有自己的模式引用表。这样的设计有什么优缺点?还是建议把它放在一个模式中?请指教。

All these webapps will often be used by the same organizations/users. Is it good idea to create separate schemas for each application and create foreign keys between them? For example webapp for managing orders will have it's own schema, member system will have it's own schema and tables of ordering webapp will reference tables in member schema (because an order has an owner = organization, user etc.). Later auction webapp will have it's own schema referencing tables in member system schema. What are pros and cons of such design? Or would you recommend to put it all in one schema? Please advise.

谢谢。

推荐答案

为安全起见,每个应用程序的数据库设计

You want to separate the database design for each app


  • 保持整洁的

  • 等等

另一方面,您要与用户信息共享同一张表,不想放弃外键关系。我也不会省略它。

On the other hand you want to share the same table with user information and don't want to abstain from foreign key relationship. I wouldn't omit it either.

所以,这样做如何:

有一个模式,其中您只保留用户信息。在这个表上,您将插入一个触发器,插入后将其插入到所有其他应用程序模式中的相同表格中。

因此,当您创建新用户时,您只需输入一个条目你的成员表在主模式中。它只是写。在每个应用程序的每个模式中,您有另一个成员表(可以由外键引用),这是一个只读表。

Have one schema, in which you only maintain your user information. On this table(s) you put a trigger, which after an insert inserts the row into the same tables in all your other app's schemas.
So when you create a new user, you just make an entry in your members table in the main schema. It's write only. In each schema for each app you have another members table (which can be referenced by foreign keys), which is a read only table.

这篇关于我应该为每个Web应用程序创建特殊的模式,还是将其全部放在一个模式中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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