如何证明两个数据模型逻辑上等价?

问题描述 投票:0回答:1

假设 Alice 有一个数据模型:

Person: {
    id: int (unique not null),
    name: string,
    phone_number: string
}

Bob 建议 Alice 也可以使用以下数据模型:

Person: {
    id: int (unique not null),
    name: string
}

Number: {
    person_id: int (fk Person(id) not null),
    phone_number: string
}

Alice 问 Bob“这两个模型等效吗?”

理论上,单个字符串字段可以存储任意数据,因此从某种意义上说,Alice 和 Bob 的模型都可以建模任何东西,因此 Alice 可以存储 Bob 的数据,反之亦然。这感觉不是一个非常令人满意的两个模型等效的概念。

一般来说,数据模型之间的形式逻辑/语义“等价”有哪些有用的定义,以及我们如何确定两个数据模型是等价的?

database database-design
1个回答
0
投票

一般来说,数据模型之间的形式逻辑/语义“等价”有哪些有用的定义,以及我们如何确定两个数据模型是等价的?

首先,关系代数是最自然、最规范的,在集合论上按一阶建模:关系是一组元组某某,然后存在诸如投影和连接之类的操作。 (这不是简单的集合论,其中一切都是集合并且集合包含集合,并且在许多方面它比简单的集合论更简单/更受限制,但我将委托给下面链接的论文进行正式处理。)

也就是说,就“等价”是一个定义的概念而言,任何等价问题的答案通常取决于所使用的具体定义。另一方面,任何这样的定义都不是完全任意的:至少它应满足使其成为“等价关系”的标准。此外,利用“内涵”(或“名义”)与“外延”的区别,我们可以在本质上具有两个极端(两个极点)的范围内定义同一性和/或等价性,并提出问题:内涵(又名名义)名称上的完全平等,而不仅仅是形状上的平等;外延是内容/数据的等价(如两个集合“相等”,如果它们包含相同的元素),即,如果两个关系表示同一组元组,则它们是等价的。 这仍然是非正式的且不完全精确(同样,我将不得不委托更正式的处理),但为了直观地理解名义与外延的区别,请考虑这个基本示例:下表“等效”吗? CatTypes { ID auto PK Title text UK Order int IX } ItemTypes { ID auto PK Name text UK Sorting int IX } 很明显,从严格名义上的角度来看,它们并不是(即使只是表名的改变也使它们不同:而且它们确实是不同的,至少在某些语义层面上是潜在的);而从外延的角度来看,很明显它们表达了完全相同的结构和约束,并且从这个意义上说它们确实是等价的。 最终,在我们的例子中,等价概念是如何相关的也可能是显而易见的,例如为了证明模式和查询转换的正确性,而是

扩展的

:换句话说,我们

在这里处理语义。
现在我委托进行更正式的治疗:

使用关键字“等价关系模式”搜索,我找到了两篇关于模型/模式等价的具体问题的技术论文(仅此而已),幸运的是,它们都是免费提供的。请注意,从我上面概述的意义上来说,他们对等价的定义确实是一种扩展定义:简单地说,两个模型/模式是等价的,如果它们(可以)表示相同的数据

关系数据库方案的等价性(1979)

这是摘要: >

关系数据库模式之间的包含和等价(1982)
简介摘录:

><< We investigate the question of when two database schemes embody the same information. We argue that this question reduces to the equivalence of the sets of fixed points of the project-join mappings associated with the two database schemes in question. When data dependencies are given, we need only consider those fixed points that satisfy the dependencies. A polynomial algorithm to test the equivalence of database schemes, when there are no dependencies, is given. We also provide an exponential algorithm to handle the case where there are functional and/or multivalued dependencies. Furthermore, we give a polynomial time test to determine whether a project-join mapping preserves a set of functional dependencies, and a polynomial time algorithm for equivalence of database schemes whose project-join mappings do preserve the given set of functional dependencies. Lastly, we introduce the "update sets" approach to database design as an application of these results. >

将数据库模式的比较基于回答查询的能力;

不仅要考虑垂直变换,还要考虑水平变换,甚至更一般的变换;

建立一个框架,在假设普遍关系存在和不存在时都可以比较数据库模式;<< In order to formalize these comparisons and relationships there is the need of precise definitions of conceptual relations among database schemata, that is, relations that compare the ability of database schemata to represent information and answer to queries. >

允许比较可以定义任何类型的完整性约束的数据库模式。 >>

<< The main characteristics of our approach are:

    [我确信我的答案可以改进,这更多的是第一个近似值:我期待任何反馈/建议/反对。]
© www.soinside.com 2019 - 2024. All rights reserved.