多值数据库 (UniVerse) -- SM (MV) 与 SM (VS) 和 ASSOC()

发布于 2024-08-17 00:16:58 字数 2114 浏览 5 评论 0原文

我有一个来自 IBM 的嵌套关系的第 16 页的问题数据库白皮书,我很困惑为什么在下面的CREATE命令中他们使用MV/MS/MS而不是MV/MV/MS,当两者ORDER_#PART_#一对多关系。我不明白值和子值在非 1nf 数据库设计中意味着什么。我还想了解有关 ASSOC () 子句的更多信息。

IBM 嵌套关系数据库白皮书第 16 页(略有空格修改)

    CREATE TABLE NESTED_TABLE (
      CUST# CHAR (9) DISP ("Customer #),
      CUST_NAME CHAR (40) DISP ("Customer Name"),
      ORDER_# NUMBER (6) DISP ("Order #") SM ("MV") ASSOC ("ORDERS"),
      PART_# NUMBER (6) DISP (Part #") SM ("MS") ASSOC ("ORDERS"),
      QTY NUMBER (3) DISP ("Qty.") SM ("MS") ASSOC ("ORDERS")
    );

IBM 嵌套关系数据库将嵌套表实现为重复属性和 重复关联的属性组。 SM 子句指定该属性是重复(多值 - “MV”)或重复组(多子值 - “MS”)。 ASSOC 子句将嵌套表中的属性关联起来。如果需要,IBM 嵌套关系数据库可以支持基表中的多个嵌套表。需要使用以下标准 SQL 语句来处理图 5 的 1NF 表以生成图 6 所示的报告:

    SELECT CUSTOMER_TABLE.CUST#, CUST_NAME, ORDER_TABLE.ORDER_#, PART_#, QTY
    FROM CUSTOMER_TABLE, ORDER_TABLE, ORDER_CUST
    WHERE CUSTOMER_TABLE.CUST_# = ORDER_CUST.CUST_# AND ORDER_CUST.ORDER_# =
    ORDER _TABLE.ORDER_#;

                                       Nested Table
                Customer #       Customer Name Order #        Part #   Qty.
                AA2340987        Zedco, Inc.      93-1123     037617   81
                                                              053135   36
                                                  93-1154     063364   32
                                                              087905   39
                GV1203948        Alphabravo       93-2321     006776   72
                                                              055622   81
                                                              067587   29
                MT1238979        Trisoar          93-2342     005449   33
                                                              036893   52
                                                              06525    29
                                                  93-4596     090643   33

I have a question taken from pg 16 of IBM's Nested Relational Database White Paper, I'm confused why in the below CREATE command they use MV/MS/MS rather than MV/MV/MS, when both ORDER_#, and PART_# are one-to-many relationships.. I don't understand what value, vs sub-value means in non-1nf database design. I'd also like to know to know more about the ASSOC () clause.

Pg 16 of IBM's Nested Relational Database White Paper (slight whitespace modifications)

    CREATE TABLE NESTED_TABLE (
      CUST# CHAR (9) DISP ("Customer #),
      CUST_NAME CHAR (40) DISP ("Customer Name"),
      ORDER_# NUMBER (6) DISP ("Order #") SM ("MV") ASSOC ("ORDERS"),
      PART_# NUMBER (6) DISP (Part #") SM ("MS") ASSOC ("ORDERS"),
      QTY NUMBER (3) DISP ("Qty.") SM ("MS") ASSOC ("ORDERS")
    );

The IBM nested relational databases implement nested tables as repeating attributes and
repeating groups of attributes that are associated. The SM clauses specify that the attribute is either repeating (multivalued--"MV") or a repeating group (multi-subvalued--"MS"). The ASSOC clause associates the attributes within a nested table. If desired, the IBM nested relational databases can support several nested tables within a base table. The following standard SQL statement would be required to process the 1NF tables of Figure 5 to produce the report shown in Figure 6:

    SELECT CUSTOMER_TABLE.CUST#, CUST_NAME, ORDER_TABLE.ORDER_#, PART_#, QTY
    FROM CUSTOMER_TABLE, ORDER_TABLE, ORDER_CUST
    WHERE CUSTOMER_TABLE.CUST_# = ORDER_CUST.CUST_# AND ORDER_CUST.ORDER_# =
    ORDER _TABLE.ORDER_#;

                                       Nested Table
                Customer #       Customer Name Order #        Part #   Qty.
                AA2340987        Zedco, Inc.      93-1123     037617   81
                                                              053135   36
                                                  93-1154     063364   32
                                                              087905   39
                GV1203948        Alphabravo       93-2321     006776   72
                                                              055622   81
                                                              067587   29
                MT1238979        Trisoar          93-2342     005449   33
                                                              036893   52
                                                              06525    29
                                                  93-4596     090643   33

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

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

发布评论

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

评论(2

看透却不说透 2024-08-24 00:16:58

我将继续回答我自己的问题,同时追求 IBM 针对 DBA 的 UniVerse SQL 管理 我在第 55 页遇到了 CREATE TABLE 代码。

ACT_NO INTEGER FORMAT '5R' PRIMARY KEY
BADGE_NO INTEGER FORMAT '5R' PRIMARY KEY
ANIMAL_ID INTEGER FORMAT '5L' PRIMARY KEY

(请参阅令人分心的

>旁注下面)一开始这让我很有趣,但本质上我相信这是一个列指令,与 PRIMARY ( ACT_NO, BADGE_NO, ANIMAL_ID )稍后页面中的 5-19,我看到了这个

ALTER TABLE LIVESTOCK.T ADD ASSOC VAC_ASSOC (
    VAC_TYPE KEY, VAC_DATE, VAC_NEXT, VAC_CERT
);

,这让我相信在列上附加 ASSOC (VAC_ASSOC) 是一样的......就像这样

CREATE TABLE LIVESTOCK.T (
    VAC_TYPE ... ASSOC ("VAC_ASSOC")
    VAC_DATE ... ASSOC ("VAC_ASSOC")
    VAC_NEXT ... ASSOC ("VAC_ASSOC")
    VAC_cERT ... ASSOC ("VAC_ASSOC")
);

无论如何,我不是 100% 确定我是是的,但我猜顺序并不重要,而且这些不是不及物关联,而是对顺序不敏感的分组。

向前!对于与 MSMV 相关的问题的第二部分,我一生都无法弄清楚 IBM 到底从哪里得到这个语法。我相信这是想象出来的。我无法访问可以用来测试这一点的开发机器,但我在旧的 10.1 或新的 UniVerse 10.3 SQL 参考

旁注给那些不习惯 UniVerse 5R 和 5L 表示右对齐或左对齐 5 个字符。这就是表元数据中内置的显示功能...Google 搜索 UniVerse FORMAT(或 FMT)以获取更多信息。

I'll go ahead and answer my own question, while pursuing IBM's UniVerse SQL Administration for DBAs I came across code for CREATE TABLE on pg 55.

ACT_NO INTEGER FORMAT '5R' PRIMARY KEY
BADGE_NO INTEGER FORMAT '5R' PRIMARY KEY
ANIMAL_ID INTEGER FORMAT '5L' PRIMARY KEY

(see distracting side note below) This amused me at first, but essentially I believe this to be a column directive the same as a table directive like PRIMARY ( ACT_NO, BADGE_NO, ANIMAL_ID )

Later on page 5-19, I saw this

ALTER TABLE LIVESTOCK.T ADD ASSOC VAC_ASSOC (
    VAC_TYPE KEY, VAC_DATE, VAC_NEXT, VAC_CERT
);

Which leads me to believe that tacking on ASSOC (VAC_ASSOC) to a column would be the same... like this

CREATE TABLE LIVESTOCK.T (
    VAC_TYPE ... ASSOC ("VAC_ASSOC")
    VAC_DATE ... ASSOC ("VAC_ASSOC")
    VAC_NEXT ... ASSOC ("VAC_ASSOC")
    VAC_cERT ... ASSOC ("VAC_ASSOC")
);

Anyway, I'm not 100% sure I'm right, but I'm guessing the order doesn't matter, and that rather than these being an intransitive association they're just a order-insensitive grouping.

Onward! With the second part of the question pertaining to MS and MV, I for the life of me can not figure out where the hell IBM got this syntax from. I believe it to be imaginary. I don't have access to a dev machine I can play on to test this out, but I can't find it (the term MV) in the old 10.1 or the new UniVerse 10.3 SQL Reference

side note for those not used to UniVerse the 5R and 5L mean 5 characters right or left justified. That's right a display feature built into the table meta data... Google for UniVerse FORMAT (or FMT) for more info.

有深☉意 2024-08-24 00:16:58

如您所知,属性、多值和子多值来自它们构建数据的方式。

本质上,所有数据都存储在排序树中。
UniVerse 是一个多值数据库。一般来说,它不像关系型数据库的SQL工作功能那样工作。

每条记录可以有多个属性。

每个属性可以有多个多值。

每个多值可以有多个子多值。

因此,如果我有一条名为 FRED 的记录

,则 FRED<1,2,3>指的是第 1 个属性、2 个多值位置和 3 个子值位置。

要了解更多信息,您需要了解有关 UniVerse 工作原理的更多信息。 SQL部分只是它的一个侧面部分。我建议您阅读其他手册以了解您正在使用的内容。

编辑

本质上,上面的代码告诉您:

每个客户可能有多个订单。这些以 MV 级别存储在“表”中。

每个订单可能有多个部件。这些存储在 MS 级别的“表”中。

每个订单可能有多个数量。这些信息存储在 MS 级别的“表”中。由于是同一级别,虽然订单上是1-n,但零件上却是1-1。

Just so you know, Attribute, Multivalue and Sub-Multivalue comes from the way they structure their data.

Essentially, all data is stored in a tree of sorts.
UniVerse is a Multivalue Database. Generally, it does not work in the say way as Relational DBs of the SQL work function.

Each record can have multiple attributes.

Each attribute can have multiple multivalues.

Each multivalue can have multiple sub-multivalues.

So, if I have a record called FRED

Then, FRED<1,2,3> refers to the 1st attribute, 2 multivalue position and 3 subvalue position.

To read more about it, you need to learn more about how UniVerse works. The SQL section is just a side part of it. I suggest you read the other manuals to understand what you are working with.

EDIT

Essentially, the code above is telling you that:

There may be multiple orders per client. These are stored at an MV level in the 'table'

There may be multiple parts per order. These are stored at the MS level in the 'table'

There may be multiple qtys per order. These are stored at the MS level in the 'table'. since they are at the same level, although they are 1-n for orders, they are 1-1 in regards to parts.

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