Rational Database Design Process 关系数据库设计过程一——定义“关系”(译)
最近在做数据库设计,拿到一本ms press 的 《Designing Relational Database Systems》E文,看了几遍关系数据库设计过程一节,还是没记得住,决定仔细译一下。版权问题,扼要的译。
Defining Relationships
After you've been through all your source documents, you'll have a draft description of the entities and attributes in the problem space. Two tasks remain: establishing the relationships between these entities, and reviewing each entity's attributes and constraints.
在当你过了一遍所有你的源文档后,你就会对问题域里实体及其属性有一个大概的了解。还有两项工作:在实体间建立他们之间的关系和检查实体的每一个属性和属性的约束。
Although theoretically you could review the attributes first, I find it easiest to start with the relationships, since some of these will become additional entities and some will require that attributes be added to entities you've already identified.
虽然理论上你应该先复查实体的属性先,但我发现从它他的关系入手将简单的多,它们之中的一些将被提取出来成新的实体而有一些则需要添加新的属性。
If you're like me, what you have after your first pass through the source documents is a bunch of handwritten notes with arrows and scribbles and "see page 12"s that nobody else could possibly decipher. So the first step in defining relationships is to get these organized neatly. You can start by building the first draft of the Entity Relationship (E/R) diagram of your data model. (If your notes are really messy and you're worried that even you might not be able to read them in three weeks, you might also list the attributes you've identified for each entity.)
如果你和我一样,你将在过了一遍所有的源文档后便用一些符号和手写注释起草,写一些诸如“请看第12页”这些无人知晓的东东。所以定义“关系”的第一步应该先把所有的东东齐整的组织一下。你可以根据你的数据模型的ER图来开始建立先张草图。(如果你的注释着实零乱,而且你害怕三个星期后你可能会忘记,你也可以把每一实体的属性列出来。)
Start by choosing an entity, usually one of the core entities in the system, and then add the entities that have some relationship with it. You can define the nature of the relationships (one-to-one, one-to-many, many-to-many) as you go, or you can simply draw a straight line to remind yourself that there is a relationship, and then come back and analyze it later. 从选择单一的实体开始,通常是系统的核心实体。然后添加一些与核心实体相关的实体。接着定义“关系”的种类(就是“关系”的内在属性)(一对一、一对多、多对多),或者你只是简单的画一条直线来提醒自己这里有一个“关系”,待后回来再加分析。
The first draft of the E/R diagram for the order-processing example is shown in Figure 9-4. This is a simple example, and the diagram is quite easy to read. (Assume we've decided that Salesperson is an attribute only of the Sales Order entity and not an entity in its own right.) If you're working on a complex example, you might want to create multiple diagrams, each one describing only a subset of the data. In this case, it's a good idea to use some sort of automated support for the diagrams. Otherwise, making sure they're synchronized can get tedious.
下面的是“订单过程”的实体-关系图的首张草图。这是一个简单的例子,图也很好理解(假设我们只把销售人作为销售订单的一个属性,而不是作为一独立的实体)。如果你在做一个比较复杂的例子,你也许会创建多的图,每一个图展示数据的子集。在这种情况下,你最好使用一些图的自动化支持,不然,使它们同步将乏味异常。
Once you have your draft E/R diagram prepared, you can begin to analyze the relationships in more detail. For each relationship, you want to determine the following:
当你准备好你的实体-关系草图后便可以更详细的分析这些“关系”了。对于每一个“关系”,你须确定如下几项:
- The cardinality of the relationship “关系”的基数
- The optionality of each participant 参与者的可选性
- Any attributes of the relationship “关系”的所有属性
- Any constraints on the relationship “关系”的所有约束

The Cardinality of the Relationship
The Cardinality of the Relationship
The Cardinality of the Relationship
The Cardinality of the Relationship
Where you discover a many-to-many relationship, you should add the junction entity to the model, with a one-to-many relationship on each side. The relationship between Supplier and Product in our model is many-to-many, and so we need to add the entity Product Supplier to resolve it. Note that the relationship between Sales Order and Product is also many-to-many, but in this case the Order Detail entity functions as the junction.
当你发现模型里存在“多对多”的关系,你必须添加一个新的实体作连接作用,使每一端只存在“一对多”的关系。在我们的模型中,供应商和商品之间是多对多的关系,所以我们添加了一个“商品供应商”实体分解它们。
The Optionality of the Relationship
The Optionality of the Relationship
The Optionality of the Relationship
The Optionality of the Relationship
Having established the kind of the relationship between any two entities, you should now consider whether the relationship is optional for either or bo

