帮助我联系继承和关系概念 [英] Help me to connect inheritance and relational concepts

查看:83
本文介绍了帮助我联系继承和关系概念的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与我的一位编程人员讨论继承及其在设计模型中的用途.他是一个大支持者,而我则有点不温不火.通常是因为我倾向于从下而上地设计系统:数据库->应用程序->演示文稿(老实说,我不是一个前端人员,所以我经常将演示文稿完全交给其他人使用).我发现关系数据库系统如果不与其他表建立大量的一对一关系,就不支持继承.

I was talking with a programmer pal of mine about inheritance and its use in designing models. He's a big proponent and I'm a little more tepid. Mostly because I tend to design systems from the bottom up: Database -> Application -> Presentation (honestly, I'm not much of a front-end guy, so I often leave presentation entirely to someone else). I find that relational database systems don't support inheritance without a lot of 1-to-1 relationships to other tables.

如果从概念的角度进行设计,则管理员就是用户就是人.从数据库开始,管理员是UserType ="Administrator"的用户.对我来说,协调这些方法似乎很困难,因此,我仅对非持久对象使用继承.

If I'm designing from a conceptual standpoint, an Administrator is a User is a Person. Starting from the database up, an Administrator is a User with UserType = "Administrator". Reconciling these approaches seems difficult to me, and therefore I only use inheritance with non-persisted objects.

我的想法出了什么问题?如果继承与传统的关系结构存在固有的不兼容性,为什么继承是OO经常被推崇的方面?或者,是我没有正确地将继承映射到关系数据吗?是否有一些指南可以帮助我解决这个问题?

What's wrong with my thinking? Why is inheritance such an oft-celebrated aspect of OO if it has these inherent incompatibilities with traditional relational structures? Or, is it me who's not mapping inheritance properly to relational data? Is there some guidance out there that might clear this up for me?

很抱歉您提出的问题,在此先感谢您的回答.如果您在响应中包含代码,则C#是我的母语".

Sorry for the rambling question and thanks in advance for your answers. If you include code in your response, C# is my "native language".

推荐答案

通常被称为

This has been popularly termed the Object-Relational Impedance Mismatch:

架构继承-大多数关系数据库不支持架构继承.尽管可以在理论上添加这种功能来减少与OOP的冲突,但是关系支持者不太可能相信分层分类法和子类型的效用,因为它们倾向于将基于集合的分类法或分类系统视为功能更强大且更灵活比树木. OO倡导者指出,继承/子类型模型不必局限于树(尽管这在许多流行的OO语言(例如Java)中是一个限制),但是非树OO解决方案被认为比基于集合的变体更难制定,关系管理人员首选的主题管理技术.至少它们与关系代数中常用的技术不同.

Schema inheritance — Most relational databases do not support schema inheritance. Although such a feature could be added in theory to reduce the conflict with OOP, relational proponents are less likely to believe in the utility of hierarchical taxonomies and sub-typing because they tend to view set-based taxonomies or classification systems as more powerful and flexible than trees. OO advocates point out that inheritance/subtyping models need not be limited to trees (though this is a limitation in many popular OO languages such as Java), but non-tree OO solutions are seen as more difficult to formulate than set-based variation-on-a-theme management techniques preferred by relational. At the least, they differ from techniques commonly used in relational algebra.

另请参见:敏捷数据 查看全文

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