数据库架构设计工具/模块化数据库设计

时间:2022-06-09 03:38:15

I'm developing applications which can be build partly from modules. For example I would be able to develop some online community which contains the modules 'forum', 'blog', 'gallery', etc.

我正在开发可以部分从模块构建的应用程序。例如,我将能够开发一些在线社区,其中包含模块“论坛”,“博客”,“图库”等。

Currently I have one large database ERM containing all the tables of all modules with foreign-key connections and I'm using dbwrench to build this ERM. However, I am not very happy with this approach. I would like to have an ERM designer, which can work in a module-oriented fashion. I would like to save the database tables in a separate schema file for each module, but keep foreign-key references between these different schemas.

目前我有一个大型数据库ERM,包含所有具有外键连接的模块的表,我正在使用dbwrench来构建此ERM。但是,我对这种方法不是很满意。我想有一个ERM设计师,它可以以面向模块的方式工作。我想将数据库表保存在每个模块的单独模式文件中,但在这些不同的模式之间保留外键引用。

However, I was not able to find any tools, which support this -- is this the wrong way to go or how to you design "modular ERM" / modular database schemes?

但是,我无法找到任何支持此工具的工具 - 这是错误的方法或如何设计“模块化ERM”/模块化数据库方案?

thanks!

谢谢!

5 个解决方案

#1


2  

I agree that modular design is the way to go. When we create applications for customers we tend to sell them a collection of widgets we have already built. So what happens when a customer says "I visited website X and I like their widget Y. Can you add this to my application/website?"

我同意模块化设计是最佳选择。当我们为客户创建应用程序时,我们倾向于向他们出售我们已经构建的小部件集合。那么当客户说“我访问过网站X而我喜欢他们的小部件Y时会发生什么呢。你可以将它添加到我的应用程序/网站吗?”

This is a good thing customer A pays for widget Z that we can then sell to all other customers. The trick is to build these widgets in such a way they so they fit without breaking the current application.

这是客户A支付小部件Z的好东西,然后我们可以销售给所有其他客户。诀窍是以这样的方式构建这些小部件,使它们适合而不会破坏当前的应用程序。

Check out this link and the sources identified in the notes.

查看此链接以及注释中标识的来源。

MediaWiki Design - See notes at the bottom

MediaWiki Design - 请参阅底部的注释

#2


2  

I am absolutely convinced, this is the right approach. Unfortunately the database community has yet to embrace such new concepts as modular design, agile software development and the like.

我绝对相信,这是正确的方法。遗憾的是,数据库社区还没有采用模块化设计,敏捷软件开发等新概念。

If I have a choice I let a ORM tool create the base of the script, and add details that don't belong into an ORM (e.g. special indexes, tablespaces, partitioning) manually, and also create migration scripts manually (which is pretty straight forward when you have the text based diffs, between the complete script in two versions.

如果我有一个选择,我让ORM工具创建脚本的基础,并手动添加不属于ORM的细节(例如特殊索引,表空间,分区),还可以手动创建迁移脚本(这非常直接当你有基于文本的差异时,在两个版本的完整脚本之间转发。

So I end up with three kind of scripts: automatically generated script that generates a new database. manually generated script that does the same, but with some added details, that are irrelevant for the functional requirements. a set of migration script that move a database from one version to the next step by step.

所以我最终得到了三种脚本:自动生成的脚本,用于生成新的数据库。手动生成的脚本执行相同操作但具有一些添加的详细信息,这些脚本与功能要求无关。一组迁移脚本,用于将数据库从一个版本逐步移动到下一个版本。

I also have a bunch of tests, that create various schemas, using combination of theses scripts and compares them.

我还有一堆测试,创建各种模式,使用这些脚本的组合并比较它们。

If I need diagrams, I create those from the schema or the code of the object model, using some reverse engineering.

如果我需要图表,我使用一些逆向工程从对象模型的模式或代码创建。

#3


1  

I keep separate database build scripts for each modules schema and just note in comments what other modules they are dependent on. I then add schema's to the database that corresponds to an application as necessary. Using normal Indexes instead of foreign keys. I've always found doing things manually is best for extremely modular tasks.

我为每个模块架构保留了单独的数据库构建脚本,并在注释中注明它们依赖的其他模块。然后,我根据需要将模式添加到与应用程序对应的数据库中。使用普通索引而不是外键。我总是发现手动操作最适合极其模块化的任务。

#4


1  

I prefer using schemas. It is a natural way to encapsulate an area of concern (be it a schema for a module or a schema to cover an information-area).

我更喜欢使用模式。这是封装关注区域的自然方式(无论是模块的模式还是模式来覆盖信息区域)。

I am using PostgreSQL and I prefer writing the db initiation myself (I want to have 100% control and SQL is as explicit as it gets.). I use SchemaSpy to generate the ER diagrams. I have had no issues with multiple schemas and foreign keys across schemas - not sure how that works in MySQL.

我正在使用PostgreSQL,我更喜欢自己编写db启动(我想要100%控制,SQL就像它得到的一样明确。)。我使用SchemaSpy生成ER图。我对模式中的多个模式和外键没有任何问题 - 不确定它在MySQL中是如何工作的。

I am not familiar with the tool you mentioned, however, a screenshot seems to reveal they support schemas. Might be worth to check again. http://www.dbwrench.com/screenshots/xp_explorer.shtml

我不熟悉你提到的工具,但截图似乎显示它们支持模式。可能值得再次检查。 http://www.dbwrench.com/screenshots/xp_explorer.shtml

As for modular design, I am not sure schemas will be sufficient, imho schemas makes it easier for the brain to make assumptions about how the data relates, it does not make anything more modular per se. Please clarify your needs on how they should be modular.

至于模块化设计,我不确定模式是否足够,imho模式使大脑更容易对数据的相关性做出假设,它本身并没有更多的模块化。请说明您对模块化方式的需求。

#5


-1  

A good database design starts with a list of the data that you want to include in your database and what you want to be able to do with the database later on. This can all be written in your own language, without any SQL. In this stage you must try not to think in tables or columns, but just think: "What do I need to know?" Don't take this too lightly, because if you find out later that you forgot something, usually you need to start all over. Adding things to your database is mostly a lot of work.

一个好的数据库设计从您希望包含在数据库中的数据列表开始,以及您希望以后能够对数据库执行的操作。这可以用你自己的语言编写,没有任何SQL。在这个阶段,你必须尽量不在表格或专栏中思考,而只是想:“我需要知道什么?”不要过于轻率,因为如果你后来发现你忘记了什么,通常你需要从头开始。向数据库添加内容主要是很多工作。

There are a lot of tools that can help you:

有很多工具可以帮助您:

Archi

阿尔奇

A free and open source visual modelling and design tool, Archi is used to create models and modelling sketches. By providing an open source reference implementation of ArchiMate, Archi is presently one of the tools used to implement the Open Group ArchiMate Model Exchange File Format. Price: Free

Archi是一个免费的开源可视化建模和设计工具,用于创建模型和建模草图。通过提供ArchiMate的开源参考实现,Archi目前是用于实现Open Group ArchiMate模型交换文件格式的工具之一。价格:免费

PowerDesigner

PowerDesigner的

PowerDesigner is arguably the industry’s leading data modelling tool. Its features include: fully integrated models, different modelling techniques that cater to both an IT-centric audience and non IT-centric. It also supports a powerful metadata repository and various output formats. It has a nice and polished user interface with easily readable help documentation aiding the user to quickly solve ad hoc problems.

PowerDesigner可以说是业界领先的数据建模工具。其功能包括:完全集成的模型,不同的建模技术,既适合以IT为中心的受众,也适用于以IT为中心的受众。它还支持强大的元数据存储库和各种输出格式。它具有漂亮而优美的用户界面,易于阅读的帮助文档帮助用户快速解决临时问题。

Price: $2,000

价格:2,000美元

SQLDbm

SQLDbm

• Pricing: Free

•定价:免费

• Forward engineering: Use SQLDBM to create a physical model or ERD of your database

•正向工程:使用SQLDBM创建数据库的物理模型或ERD

• Reverse engineering: Use the reverse engineering feature to export your database schema as a SQL script

•逆向工程:使用逆向工程功能将数据库模式导出为SQL脚本

Features:

特征:

• Create database objects like tables, objects, relationships, indexes, quickly and intuitively

•快速直观地创建表,对象,关系,索引等数据库对象

• Alter and edit database objects inline in your diagram

•在图表中内联更改和编辑数据库对象

• Copy or Move columns across tables

•跨表复制或移动列

• Zoom in and out of diagrams

•放大和缩小图表

• On-the- spot design anywhere on any browser Price: Free

•任何浏览器上的任何地方的现场设计价格:免费

#1


2  

I agree that modular design is the way to go. When we create applications for customers we tend to sell them a collection of widgets we have already built. So what happens when a customer says "I visited website X and I like their widget Y. Can you add this to my application/website?"

我同意模块化设计是最佳选择。当我们为客户创建应用程序时,我们倾向于向他们出售我们已经构建的小部件集合。那么当客户说“我访问过网站X而我喜欢他们的小部件Y时会发生什么呢。你可以将它添加到我的应用程序/网站吗?”

This is a good thing customer A pays for widget Z that we can then sell to all other customers. The trick is to build these widgets in such a way they so they fit without breaking the current application.

这是客户A支付小部件Z的好东西,然后我们可以销售给所有其他客户。诀窍是以这样的方式构建这些小部件,使它们适合而不会破坏当前的应用程序。

Check out this link and the sources identified in the notes.

查看此链接以及注释中标识的来源。

MediaWiki Design - See notes at the bottom

MediaWiki Design - 请参阅底部的注释

#2


2  

I am absolutely convinced, this is the right approach. Unfortunately the database community has yet to embrace such new concepts as modular design, agile software development and the like.

我绝对相信,这是正确的方法。遗憾的是,数据库社区还没有采用模块化设计,敏捷软件开发等新概念。

If I have a choice I let a ORM tool create the base of the script, and add details that don't belong into an ORM (e.g. special indexes, tablespaces, partitioning) manually, and also create migration scripts manually (which is pretty straight forward when you have the text based diffs, between the complete script in two versions.

如果我有一个选择,我让ORM工具创建脚本的基础,并手动添加不属于ORM的细节(例如特殊索引,表空间,分区),还可以手动创建迁移脚本(这非常直接当你有基于文本的差异时,在两个版本的完整脚本之间转发。

So I end up with three kind of scripts: automatically generated script that generates a new database. manually generated script that does the same, but with some added details, that are irrelevant for the functional requirements. a set of migration script that move a database from one version to the next step by step.

所以我最终得到了三种脚本:自动生成的脚本,用于生成新的数据库。手动生成的脚本执行相同操作但具有一些添加的详细信息,这些脚本与功能要求无关。一组迁移脚本,用于将数据库从一个版本逐步移动到下一个版本。

I also have a bunch of tests, that create various schemas, using combination of theses scripts and compares them.

我还有一堆测试,创建各种模式,使用这些脚本的组合并比较它们。

If I need diagrams, I create those from the schema or the code of the object model, using some reverse engineering.

如果我需要图表,我使用一些逆向工程从对象模型的模式或代码创建。

#3


1  

I keep separate database build scripts for each modules schema and just note in comments what other modules they are dependent on. I then add schema's to the database that corresponds to an application as necessary. Using normal Indexes instead of foreign keys. I've always found doing things manually is best for extremely modular tasks.

我为每个模块架构保留了单独的数据库构建脚本,并在注释中注明它们依赖的其他模块。然后,我根据需要将模式添加到与应用程序对应的数据库中。使用普通索引而不是外键。我总是发现手动操作最适合极其模块化的任务。

#4


1  

I prefer using schemas. It is a natural way to encapsulate an area of concern (be it a schema for a module or a schema to cover an information-area).

我更喜欢使用模式。这是封装关注区域的自然方式(无论是模块的模式还是模式来覆盖信息区域)。

I am using PostgreSQL and I prefer writing the db initiation myself (I want to have 100% control and SQL is as explicit as it gets.). I use SchemaSpy to generate the ER diagrams. I have had no issues with multiple schemas and foreign keys across schemas - not sure how that works in MySQL.

我正在使用PostgreSQL,我更喜欢自己编写db启动(我想要100%控制,SQL就像它得到的一样明确。)。我使用SchemaSpy生成ER图。我对模式中的多个模式和外键没有任何问题 - 不确定它在MySQL中是如何工作的。

I am not familiar with the tool you mentioned, however, a screenshot seems to reveal they support schemas. Might be worth to check again. http://www.dbwrench.com/screenshots/xp_explorer.shtml

我不熟悉你提到的工具,但截图似乎显示它们支持模式。可能值得再次检查。 http://www.dbwrench.com/screenshots/xp_explorer.shtml

As for modular design, I am not sure schemas will be sufficient, imho schemas makes it easier for the brain to make assumptions about how the data relates, it does not make anything more modular per se. Please clarify your needs on how they should be modular.

至于模块化设计,我不确定模式是否足够,imho模式使大脑更容易对数据的相关性做出假设,它本身并没有更多的模块化。请说明您对模块化方式的需求。

#5


-1  

A good database design starts with a list of the data that you want to include in your database and what you want to be able to do with the database later on. This can all be written in your own language, without any SQL. In this stage you must try not to think in tables or columns, but just think: "What do I need to know?" Don't take this too lightly, because if you find out later that you forgot something, usually you need to start all over. Adding things to your database is mostly a lot of work.

一个好的数据库设计从您希望包含在数据库中的数据列表开始,以及您希望以后能够对数据库执行的操作。这可以用你自己的语言编写,没有任何SQL。在这个阶段,你必须尽量不在表格或专栏中思考,而只是想:“我需要知道什么?”不要过于轻率,因为如果你后来发现你忘记了什么,通常你需要从头开始。向数据库添加内容主要是很多工作。

There are a lot of tools that can help you:

有很多工具可以帮助您:

Archi

阿尔奇

A free and open source visual modelling and design tool, Archi is used to create models and modelling sketches. By providing an open source reference implementation of ArchiMate, Archi is presently one of the tools used to implement the Open Group ArchiMate Model Exchange File Format. Price: Free

Archi是一个免费的开源可视化建模和设计工具,用于创建模型和建模草图。通过提供ArchiMate的开源参考实现,Archi目前是用于实现Open Group ArchiMate模型交换文件格式的工具之一。价格:免费

PowerDesigner

PowerDesigner的

PowerDesigner is arguably the industry’s leading data modelling tool. Its features include: fully integrated models, different modelling techniques that cater to both an IT-centric audience and non IT-centric. It also supports a powerful metadata repository and various output formats. It has a nice and polished user interface with easily readable help documentation aiding the user to quickly solve ad hoc problems.

PowerDesigner可以说是业界领先的数据建模工具。其功能包括:完全集成的模型,不同的建模技术,既适合以IT为中心的受众,也适用于以IT为中心的受众。它还支持强大的元数据存储库和各种输出格式。它具有漂亮而优美的用户界面,易于阅读的帮助文档帮助用户快速解决临时问题。

Price: $2,000

价格:2,000美元

SQLDbm

SQLDbm

• Pricing: Free

•定价:免费

• Forward engineering: Use SQLDBM to create a physical model or ERD of your database

•正向工程:使用SQLDBM创建数据库的物理模型或ERD

• Reverse engineering: Use the reverse engineering feature to export your database schema as a SQL script

•逆向工程:使用逆向工程功能将数据库模式导出为SQL脚本

Features:

特征:

• Create database objects like tables, objects, relationships, indexes, quickly and intuitively

•快速直观地创建表,对象,关系,索引等数据库对象

• Alter and edit database objects inline in your diagram

•在图表中内联更改和编辑数据库对象

• Copy or Move columns across tables

•跨表复制或移动列

• Zoom in and out of diagrams

•放大和缩小图表

• On-the- spot design anywhere on any browser Price: Free

•任何浏览器上的任何地方的现场设计价格:免费