database 使用 UML 类图设计数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21358774/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 09:10:48  来源:igfitidea点击:

Database design using UML Class Diagram

databasedatabase-designuml

提问by user3167689

I would like to design a database using UML class diagrams but I dont know how. Can someone help me. How can I design a database using UML class diagrams?

我想使用 UML 类图设计一个数据库,但我不知道如何。有人能帮我吗。如何使用 UML 类图设计数据库?

回答by Gerd Wagner

Making an SQL database model in the form of a UML class diagram from a general information design model essentially requires to

从通用信息设计模型以 UML 类图的形式制作 SQL 数据库模型本质上需要

  1. Represent all entity types (or better: classes representing object types) as classes stereotyped as «object table» using SQL datatype names and replacing the UML {id}property modifier with a «pkey» stereotype:

  2. Eliminate enumeration attributes for DBMS that do not support enumerations by connecting the object table with a corresponding enum table via a foreign key dependency arrow (a UML dependency stereotyped «fkey»): enter image description hereOtherwise, as in the case of MySQL, you can use their syntax in the model like so: enter image description here

  3. Eliminate multi-valued attributes:

    enter image description here

  4. Eliminate associations:

    1. Replace any functional association with a foreign key dependency: enter image description here
    2. Replace any many-to-many association (relationship type) with a class stereotyped as «association table» and two foreign key dependencies: enter image description here
  5. Eliminate generalization/inheritance relationships:

    enter image description here

  1. 使用 SQL 数据类型名称将所有实体类型(或更好:表示对象类型的类)表示为构造型为 «object table» 的类,并将 UML{id}属性修饰符替换为 «pkey» 构造型:

  2. 通过外键依赖箭头(UML 依赖构造型«fkey»)将对象表与相应的枚举表连接起来,消除不支持枚举的 DBMS 的枚举属性: 在此处输入图片说明否则,如 MySQL,您可以使用它们的语法在像这样的模型中: 在此处输入图片说明

  3. 消除多值属性:

    在此处输入图片说明

  4. 消除关联:

    1. 用外键依赖替换任何功能关联: 在此处输入图片说明
    2. 用构造型为“关联表”的类和两个外键依赖项替换任何多对多关联(关系类型): 在此处输入图片说明
  5. 消除泛化/继承关系:

    在此处输入图片说明

See this book chapterfor more information.

有关更多信息,请参阅本书章节

回答by Leo

you may try to start with a UML class diagram. Maybe you can find this tutorial useful - http://argouml-db.tigris.org/documentation/DB_UML_Guide.htm

您可以尝试从 UML 类图开始。也许您会发现本教程很有用 - http://argouml-db.tigris.org/documentation/DB_UML_Guide.htm

回答by Leo

You can additionally use "Relation scheme diagram" to design table relationship and clearly represent primary key / foreign key dependencies.

您可以额外使用“关系方案图”来设计表关系并清楚地表示主键/外键依赖关系。

see this tutorial.

请参阅本教程