database 自顶向下与自底向上数据库设计:真实世界的例子

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12054727/
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 08:41:12  来源:igfitidea点击:

Top-down vs. Bottom-up database design: Real world examples

databasedatabase-designdata-modeling

提问by Blow ThemUp

Ok, I can find hundreds of references on the internet of the difference between top-down database design vs bottom up database design approaches, however, I can't seeem to find any real world examples, or any inofrmation on which design is really more suitable for what circumstances.

好的,我可以在互联网上找到数百个关于自顶向下数据库设计与自底向上数据库设计方法之间差异的参考资料,但是,我似乎找不到任何真实世界的例子,或者任何关于哪种设计更重要的信息适合什么情况。

Can anyone help me out?

谁能帮我吗?

回答by Gilbert Le Blanc

I'm basing this answer on this Data ModelingWikipedia article.

我的这个答案基于这篇Data ModelingWikipedia 文章。

About half way down the Wikipedia page, there's a section called "Modeling methodologies".

在维基百科页面的大约一半处,有一个名为“建模方法”的部分。

A top down approach is used to create a new database. You model the objects at a logical level, then you apply the objects to a physical database design. For example, a relational database would need the objects to be mapped to tables.

使用自顶向下的方法来创建新数据库。您在逻辑级别对对象建模,然后将对象应用于物理数据库设计。例如,关系数据库需要将对象映射到表。

To use a real world example, a payroll system would have to have person objects, along with other objects that hold pay rules (overtime for over 40 hours a week, overtime for more than 10 hours a day, etc.). There would be a pay period object, which holds the dates of the pay period and the pay day. This description isn't a complete design. As you think about the application more, you come up with additional objects that need to exist, and additional entities that need to be part of existing objects.

举一个现实世界的例子,工资系统必须有人员对象,以及其他持有工资规则的对象(每周加班超过 40 小时,每天加班超过 10 小时等)。将有一个支付期对象,它保存支付期和支付日的日期。这个描述不是一个完整的设计。当您更多地考虑应用程序时,您会想到需要存在的其他对象,以及需要成为现有对象一部分的其他实体。

A bottom up approach is used to migrate a database from one physical database to another. Migrating from Oracle to IBM's DB2 usually requires some changes, as the column data types are not completely compatible. You would create tables based on the existing tables. Sometimes, you try to make a near exact copy, to minimize the application coding changes. Other times, you alter the table structure, usually to normalize further or to group columns together in a more logical way. Yes, the application code would have to change to accommodate the new database schema. But sometimes, the pain is worth the gain.

自底向上方法用于将数据库从一个物理数据库迁移到另一个物理数据库。从 Oracle 迁移到 IBM 的 DB2 通常需要进行一些更改,因为列数据类型不完全兼容。您将根据现有表创建表。有时,您尝试制作接近精确的副本,以尽量减少应用程序编码更改。其他时候,您会更改表结构,通常是为了进一步规范化或以更合乎逻辑的方式将列组合在一起。是的,应用程序代码必须更改以适应新的数据库架构。但有时候,付出是值得的。

I've seen lots of database migrations. They're hard to describe in a post. They are painful to work through.

我见过很多数据库迁移。它们很难在帖子中描述。他们是痛苦的工作。

回答by Thilanka Niroshana

To understand the differences between these approaches, let's consider some jobs that are bottom-up in nature. In statistical analysis, analysts are taught to take a sample from a small population and then infer the results to the overall population. Physicians are also trained in the bottom-up approach. Doctors examine specific symptoms and then infer the general disease that causes the symptoms.

要了解这些方法之间的差异,让我们考虑一些本质上自下而上的工作。在统计分析中,分析师被教导从一个小群体中抽取样本,然后将结果推断到整个群体中。医生也接受自下而上方法的培训。医生检查特定症状,然后推断导致这些症状的一般疾病。

An example of jobs that require the top-down approach include project management and engineering tasks where the overall requirements must be specified before the detail can be understood. For example, an automobile manufacturer must follow a top-down approach to meet the overall specifications for the car. If a car has the requirement that it cost less than 15,000 dollars, gets 25 miles per gallon, and seating five people. In order to meet these requirements the designers must start by creating a specification document and then drilling down to meet these requirements.

需要自上而下方法的工作示例包括项目管理和工程任务,其中必须在了解细节之前指定总体要求。例如,汽车制造商必须遵循自上而下的方法来满足汽​​车的整体规格。如果一辆汽车的价格要求低于 15,000 美元,每加仑行驶 25 英里,并且可以容纳 5 人。为了满足这些要求,设计人员必须首先创建规范文档,然后深入了解以满足这些要求。

taken from http://www.dba-oracle.com/t_object_top_down_bottom_up.htm

取自http://www.dba-oracle.com/t_object_top_down_bottom_up.htm