简体   繁体   English

关系数据库和OO语言

[英]Relational databases and OO languages

In a typical ASP.NET web application architecture, we are using a OO language such as C# and a relational database such as SQL server for data. 在典型的ASP.NET Web应用程序体系结构中,我们使用诸如C#的OO语言和诸如SQL服务器之类的关系数据库来获取数据。

I was reading a book on Linq that said "The problem is there is a gap between a OO programming language and a relational database" 我正在读一本关于Linq的书,上面写着“问题是OO编程语言和关系数据库之间存在差距”

What exactly is the author trying to imply? 作者究竟想要暗示什么?

EDIT: Thanks for the answers. 编辑:谢谢你的答案。 I am not sure I understand how LINQ would solve this problem. 我不确定我理解LINQ如何解决这个问题。 I might be wrong but it appears that LINQ is API for database communication just like ADO.NET 我可能错了,但似乎LINQ是用于数据库通信的API,就像ADO.NET一样

They are very different data models and ways of doing things. 它们是非常不同的数据模型和做事方式。 It's quite a religious argument with no quarter given and no mercy expected. 这是一个相当宗教的论点,没有任何季度,也没有任何怜悯。

It's all here: Object-relational impedance mismatch 一切都在这里: 对象关系阻抗不匹配

Object oriented programming is about modeling behavior efficiently. 面向对象编程是关于有效地建模行为。 The relational model is about modeling data efficiently. 关系模型是关于有效地建模数据。

This leads to very different models, which are incompatible in certain areas. 这导致了非常不同的模型,这些模型在某些领域是不兼容的。 It's called the object-relation impedance mismatch. 它被称为物体关系阻抗不匹配。 Google it . 谷歌吧

Ted Neward wrote a pretty good essay on it, called The Vietnam of computer science . 特德纽瓦德写了一篇相当不错的文章,称为计算机科学的越南 You can ignore most of the Vietnam part, if you want to. 如果你愿意,你可以忽略大部分的越南部分。

As for how LINQ fits into the equation: it doesn't so much solve the mismatch, but it provides a way to make communication with databases easier, relieving at least part of the pain. 至于LINQ如何适应方程式:它并没有解决不匹配问题,但它提供了一种方法,可以更轻松地与数据库进行通信,从而减轻至少部分痛苦。

One of the cornerstones of RDBMS is normalisation - which for the purposes of my point is never have the same bit of data is more than one place. RDBMS的一个基石是规范化 - 出于我的观点,从来没有相同的数据位不止一个地方。

With objects it is reasonable to assume that your SalesInvoice obj may be composed of several invoice lines object and customer object, delivery address etc and methods to go with it. 对于对象,可以合理地假设您的SalesInvoice obj可能由多个发票行对象和客户对象,交货地址等以及随之而来的方法组成。

There is a difficulty to jump between one and the other. 在一个和另一个之间跳跃是很困难的。 Take the delivery address for example do we store this in the Sales invoice table, What if its the same as the customer, what if its different? 以交货地址为例,我们将其存储在销售发票表中,如果与客户相同,如果不同,该怎么办? Do we have a delivery address table. 我们有送货地址表吗?

Its a complex issue. 这是一个复杂的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM