ER/数据建模(继承类型之间的链接

发布于 2024-11-18 12:24:20 字数 267 浏览 4 评论 0原文

是否有可能(或者出于任何原因非法)有这样的东西:

isa withforeign keylation

这是基本上是一个与其自身具有外键关系的 ISA 类。

这个想法是输出消息只是一条消息。但每条消息(或者我们称之为输入消息)都有一个关联的输出消息。这就是外键关系的需要。

这样可以吗,如果不行为什么不行?或者有更好的方法来建模吗?

谢谢。

Would it be possible (or is it illegal for any reason) to have something like this:

isa with foreign key relationship

This is basically an ISA class with a foreign-key relationship to itself.

The idea is that an output message is just simply a message. But every message (or let’s call it input message) has an associated output message. This is the need for the foreign key relationship.

Is this ok, if not why not? Or is there a better way to model this?

Thnx.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫轩蝶泪 2024-11-25 12:24:20

“输出消息”实际上是“消息”的特化。如果包含其他类型的消息,例如“输入消息”,情况会变得更有趣。具有多种替代方案的“isa”关系非常适合使用类继承的面向对象描述。

设计关系以模仿类继承提供的模式有三种主要方法。有一个表,所有与当前情况无关的属性中都插入了 NULL。有类表继承模型,其中每个子类都有一个自己的表,该表使用键和附加列的副本“扩展”(松散地使用这个词)主超类表。第三种方法是一种折衷的方法。

密钥的副本既是引用超类表的 PK 又是 FK。将值从超类表传播到子类表是通过编程完成的。基于简单连接的视图足以为您提供有关给定子类项的所有数据,无论这些数据来自超类表还是子类表。

"Output Message" is really a specialization of "Message". If some other kind of message were included, like "Input Message", the case would become more interesting. "isa" relationships with multiple alternatives lend themselves well to Object Oriented description, using class inheritance.

There are three major ways to design relations to mimic the pattern provided by class inheritance. There's the single table, with NULLs inserted in all attributes that do not pertain to the case at hand. There's the class table inheritance model, where each subclass has a table of its own that "extends" (using the word loosely) the main superclass table with a copy of the key and additional columns. The third method is sort of a compromise.

The copy of the key is both a PK and an FK that references the superclass table. Propagating the value from the superclass table to the subclass tables is done programmatically. Views based on simple joins are enough to provide you with all the data about a given subclass item, regardless of whether this data comes from the supeclass table or the subclass table.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文