我正在创建一个可以是不同类型的结构的数据库。每种类型都有一组独特的属性,例如与结构类型具体相关的材料、形状、属性。
例如,一个结构是一座桥梁,它可以具有跨度长度和桥面材料类型。
结构的另一个例子是具有高度、材料类型和厚度的墙。
我不想生成包含所有可能属性的平面表,因为可能存在多种类型的结构,并且属性很灵活,并且有许多属性要存储。
基本上,我们希望通过将独特的属性数据存储在每种结构类型的单独表中来防止记录变得太大,但我想不出一种方法来链接通用结构表以轻松指向属性表。
===================
编辑,
现在搜索“泛化专业化关系建模”,看来我想将数据建模为面向对象的结构,其父类“结构”具有继承公共信息(如桥结构、墙结构)的子类。现在唯一的问题是,我正在尝试帮助工程师制作一个简单的独立 Access 2010 数据库,但看来我正在正确生成 access 中的关系,父类的主键是子类的主键和外键类。这似乎会导致 Access 2010 内部出现问题,它希望父类的实例包含每个子类之一,这是无意义的。
基本上,我将
StructureID 作为结构、桥和墙表上的主键,桥和墙表上的主键是 StructureID 链接回结构表。我对 Access 2010 不太熟悉,不知道为什么它不起作用。
来自 IBM 论文之一,
基本上想要在 Access 2010 中进行此操作。
I am creating a database of structures that can be of different types. Each of the types has a set of unique attributes such as the materials, shape, properties related specifically to the type of structure.
For instance, a structure is a bridge which can have a span length and material type for the deck.
Another instance of a structure would be a wall which has a height and material type and thickness.
I do not want to generate a flat table that contains all possible attributes as there are many types of structures that could exist and the attributes are flexible and there are numerous attributes to store.
Basically we want to prevent records from getting too large by storing unique attribute data in a separate table for each type of structure but I can't think of a way to link the generic structure table to point to the attribute tables easily.
====================
EDIT,
Now that searched for "generalization specialization relational modeling" it appears that I want to model the data as a object oriented structure with a parent class "structure" that has child classes that inherit the common information as bridge structure, wall structure. The only issue now is that I am trying to help a engineer make a simple stand alone Access 2010 database but it appears that I am correctly generating the relationships within access with the primary key of the parent class being the primary and foreign key of the child classes. This appears to cause an issue inside Access 2010 where it wants instances of the parent to contain one of each child class which is non-sense.
Basically I have,
StructureID as the primary key on both structure, bridge, and wall tables on the bridge and wall table their primary key which is the structureID links back to the structure table. I am not too familiar with Access 2010 and don't know why it doesnt work.
From one of the IBM papers,
Basically want to make this in an Access 2010.
发布评论
评论(3)
我建议尝试尽可能地将结构拆分为单独的表。
您还可以拥有一个包含所有结构及其公共属性的主表。
另一种方法是使用 xml 类型列,它可以像任何 xml 一样灵活,或者您可以应用架构来强制数据完整性。
您基本上需要在这两个选项之间进行平衡。
数据库设计还取决于您的 DBMS 功能。例如,并非所有数据库都支持 XML 类型。
[编辑]
表结构可能如下所示:
结构
桥
墙壁
I suggest trying to split the structures into separate tables as much as you can.
You can also have a master table with all the structures and their common properties.
Another approach is to have xml type column, which can be as flexible as any xml or you can apply schema to enforce data integrity.
You basically need to balance between those two options.
Database design also depends on your DBMS capabilities. For example, not all databases support XML types.
[Edit]
The table structure could be like this:
Structure
Bridge
Wall
您的案例看起来像是一代规格设计模式的一个实例。如何设计关系表来反映gen-spec的问题之前已经被提出过。
查看一个主题。
Your case looks like an instance of the gen-spec design pattern. The question of how to design relational tables to reflect gen-spec has been brought up before.
See one thread.
我认为您在 Access 中设置依赖项的方式可能犯了一个小错误。似乎您需要一对一或一对零或一。
I think you may have made a small error in the way you set up the dependancies in Access. Seems you have one-to-one where you need one-to-zero-or-one.