English 中文(简体)
设计一个组织完善和正常化的关系数据库的步骤
原标题:Steps to design a well organized and normalized Relational Database

我刚刚开始为我的网站建立一个数据库,所以我正在重新阅读 Database Systems - 设计、执行和管理(第九版) ,但我注意到,书中没有任何一步一步一步的描述过程可以建立一个组织完善和标准化的数据库。这本书似乎有点遍及各地,尽管正常化进程都集中在一个地方,但导致它的步骤却并非如此。

我认为把所有步骤都放在一个清单中是非常有益的,但我找不到任何网上或其他任何地方的步骤。 我知道,解释所有步骤的回答人会说得相当广泛,但是,我能得到的关于这个议题的任何信息都会非常感激,包括正常化之前的指示顺序和与建议的联系。

虽然我半熟于这个过程, 但我在设计任何数据库时都休息了很长时间(大约1年),

我特别感兴趣的是:

  • Whats a good approach to begin modeling a database (or how to list business rules so its not confusing)

我想使用ER或ER(扩展实体关系模式),我想知道

  • how to model subtypes and supertypes correctly using EER(disjoint and overlapping) (as well as writing down the business rules for it so you know that its a subtype if there is any common way of doing that)

(我已经熟悉正常化进程,但答案也可以包括有关该进程的提示)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

  • Writing down business rules (including business rules for subtypes and super types in EER)
  • How to use subtypes and super-types in EER correctly (how to model them)

任何其他建议将不胜感激。

最佳回答

为了设计一个体面的数据库(当然,你需要首先了解数据库设计的基本内容),我重新阅读了这本书和一些在线文章,并编制了一个简短的步骤清单,下文将更详细地说明这些步骤:

(书中描述了很多步骤: Database Systems - 设计、执行和管理(第九版) , 并且这些页码也指着这些页码,但我将尽量在这里描述,并在以后几天内编辑这个答案,使其更加完整)

  1. Create a detailed narrative of the organization’s description of operations.
  2. Identify the business rules based from the description of operations.
  3. Identify the main entities and relationships from the business rules.
  4. Translate entities/relationships to EER model
  5. Check naming conventions
  6. Map ERR model to logical model (pg 400)*
  7. Normalize logical model (pg 179)
  8. Improve DB design (pg 187)
  9. Validate Logical Model Integrity Constraints (pg 402) (like length etc.)
  10. Validate the Logical Model against User Requirements
  11. Translate tables to mySQL code (in workbench translate EER to SQL file using export function then to mySQL)

*你可以跳过这一步 如果你使用工作台 和工作 和工作 ER模型的工作 你设计在那里。


1.
Describe the workings company in great detail. If you are creating personal project describe it in detail if you are working with a company ask for documents describing their company as well as interviewing the employees for information (interviews might generate inconsistent information make sure to check with supervisers which information is more important for design)
2.
Look at the gathered information and start generating rules from them make sure to fill in any information gaps in your knowledge. Confirm with supervisers in the company before moving on.
3.
Identify the main entities and relationships from the business rules. Keep in mind that during the design process, the database designer does not depend simply on interviews to help define entities, attributes, and relationships. A surprising amount of information can be gathered by examining the business forms and reports that an organization uses in its daily operations. (pg 123)


4.
If the database is complex you can break down the ERD design into followig substeps
i) Create External Models (pg 46)
ii) Combine External Models to form Conceptual Model (pg 48)

Follow the following recursive steps for the design (or for each substep) 
    I.   Develop the initial ERD.
    II.  Identify the attributes and primary keys that adequately describe the entities.
    III. Revise and review the ERD.
    IV.  Repeat steps until satisfactory output

You may also use entity clustering to further simplify your design process.

Describing database through ERD: Use solid lines to connect Weak Entities (Weak entities are those which cannot exist without parent entity and contain parents PK in their PK). Use dashed lines to connect Strong Entities (Strong entities are those which can exist independently of any other entity)

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\你的姓名是否遵循你的命名公约。我曾经有建议命名公约 在这里命名公约的建议 但人们并不真正喜欢它们。 我建议遵循你自己的标准 或者在网上寻找一些命名公约。 请发表评论, 如果你发现一些命名公约非常有用的话。 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

6. Logical design generally involves translating the ER model into a set of relations (tables), columns, and constraints definitions.

使用这些步骤将ER转换为逻辑模型:

  1. Map strong entities (entities that dont need other entities to exist)
  2. Map supertype/subtype relationships
  3. Map weak entities
  4. Map binary relationships
  5. Map higher degree relationships

7. 使逻辑模型正常化。您还可以使逻辑模型失去正常化,以便获得某些理想的特性。 (如改进性能)

<强>8.

  1. Refine Attribute Atomicity - It is generally good practice to pay attention to the atomicity requirement. An atomic attribute is one that cannot be further subdivided. Such an attribute is said to display atomicity. By improving the degree of atomicity, you also gain querying flexibility.

  2. Refine Primary Keys as Required for Data Granularity - Granularity refers to the level of detail represented by the values stored in a table’s row. Data stored at their lowest level of granularity are said to be atomic data, as explained earlier. For example imagine ASSIGN_HOURS attribute to represent the hours worked by a given employee on a given project. However, are those values recorded at their lowest level of granularity? In other words, does ASSIGN_HOURS represent the hourly total, daily total, weekly total, monthly total, or yearly total? Clearly, ASSIGN_HOURS requires more careful definition. In this case, the relevant question would be as follows: For what time frame—hour, day, week, month, and so on—do you want to record the ASSIGN_HOURS data? For example, assume that the combination of EMP_NUM and PROJ_NUM is an acceptable (composite) primary key in the ASSIGNMENT table. That primary key is useful in representing only the total number of hours an employee worked on a project since its start. Using a surrogate primary key such as ASSIGN_NUM provides lower granularity and yields greater flexibility. For example, assume that the EMP_NUM and PROJ_NUM combination is used as the primary key, and then an employee makes two “hours worked” entries in the ASSIGNMENT table. That action violates the entity integrity requirement. Even if you add the ASSIGN_DATE as part of a composite PK, an entity integrity violation is still generated if any employee makes two or more entries for the same project on the same day. (The employee might have worked on the project a few hours in the morning and then worked on it again later in the day.) The same data entry yields no problems when ASSIGN_NUM is used as the primary key.

  3. 试着回答问题:“谁可以使用表格,表格的哪些部分可以使用?” ETC。

请留下建议或链接,在下面的评论中作更清楚的描述。

问题回答

我推荐你这段关于E/R模型制作的视频(约9至9段),

http://www.youtube.com/watch?v=q1GaaghHAqM" rel=“nofollow">http://www.youtube.com/watch?v=q1GaahHAqM

<强度 > EDIT:

" 这个模型的图表必须有多大范围? 它们必须包括所有实体和属性吗? "

是的,实际上你有ER建模和扩展ER建模,

想法是使扩展ER建模, 因为您不仅指定了实体, 您还会指定 PK 和 FK 以及基本内容 。 请查看此 < a href=" http:// en. wikipedia. org/ wiki/ Entity% E2% 80% 93 relationship_ model" rel=“ nofollow” >link (参见图形和两个模型之间的差异) 。

建模有两种方式, 一种是真实的情景,另一种是 DB, I. E. 的真正结构:

当您创建 E-ER 模型时,您会为所有实体创建连线关系和基本内容,但当您要创建 DB 时,无需与 1:N 建立关系。 N (以 N 为主的表格用卡片从表格中创建 FK,而您不需要在 DB 中创建关系表),或者当您拥有 1:1 基本内容时,您知道您的一个实体可以吸收另一个实体。

< a href=" http://www.google.com/imgres?q=extend% 20entity%20relationship%20modelation@20design&um=1&hl=en&client=forox-a&org.mozilla%3a-US%3offical&channel=fflb&biw=1600&bih=720&b=740;tb=isch&t=amp;tb=2025=202020entity%20relationity%20relationity%20rematity%2020deignation%2020deignandet&2020=20=20=203xxxmexrfurl=http://asads=xampMub-q5&imurl=http://sadsiddiamp;furs;

但记住那些只是"规则" 如果你的设计需要,为了性能,安全,等等, 你可以打破它。

关于工具,有很多工具, 但我推荐了< a href=" http://dev.mysql.com/ downloads/workbench/" rel="no follow" >workbench , 因为您可以使用它连接到您的 DBs (如果你在 Mysql), 并创建带有属性的 E/R 模型设计, 他将自动创建关系表 N: M 。

<强 > EDIT2:

我在这里提出了一些链接,可以解释, 稍微好一点, 它需要很多的线条, 并且会更难解释 这里和我自己, 请回顾这个链接,

类型和子类型:

商业规则(廉正限制)