单表继承会导致非规范化 [英] Does single table inheritance results in denormalization

查看:94
本文介绍了单表继承会导致非规范化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试提出付款方式的数据模型。可以使用多种付款方式,例如卡,银行转帐,电子钱包,这些付款方式可以进一步分类为:将卡转换为信用卡/借记卡,将银行转帐至ACH / SEPA等。

We're trying to come up with the data model of Payment Method. There can be several kinds of payment methods like Card, Bank Transfer, Wallet, which further can be categorized for e.g. Card into credit/debit cards, Bank Transfer into ACH/SEPA and the like.

因此,这是关于将继承建模到数据库表中。一种选择是使用单表继承。我团队中的高级人员将单个表称为非规范化表。但我不明白为什么?我在这里看不到任何插入/删除/更新异常,每个付款方式记录都独立存在,没有多余之处。只是表中会有很多空值,因为列集将是所有付款方式的并集。

So this is about modelling inheritance into database tables. One option is to use single table inheritance. Senior folks in my team call single table as denormalized table. But I don't understand why? I don't see any insert/delete/update anomalies here, each payment method record is independent in its own, there are no redundancies. It's just there will be lots of nulls in the table as set of columns will be union of all payment methods.

推荐答案

可能是正确的。通常,具有null的超类型表是通用属性表&的左连接。一些子类型表。 (联接的并集。)但是归一化无损地分解为投影和投影。非规范化通过自然连接消除了这种情况。因此,此处对较小表的重新排列可能不是规范化和由于我们标准化&的原因未完成重组可能不是非正规化。因此,非规范化 规范化被滥用。尽管如此,即使他们使用了错误的单词,仍然存在问题。您为什么不问他们这是什么意思?

You are probably right. Typically a supertype table with nulls is the left join of a common-attribute table & some subtype tables. (A union of joins.) But normalization losslessly decomposes to projections & denormalization undoes that via natural join. So here the rearrangement to smaller tables is probably not normalization & is not done for the reasons we normalize & recombining is probably not denormalization. So "denormalized" & "normalized" are misused. Still--even if they use the wrong word there can still be a problem. Why don't you ask them what they mean?

这篇关于单表继承会导致非规范化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆