tags:

views:

204

answers:

4

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.

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"

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. I might be wrong but it appears that LINQ is API for database communication just like ADO.NET

+6  A: 

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

gbn
What do you mean it's a religious argument?
Rik
It is a saying (not literal). He means that it there are people on both sides that are 'smitten' with their technology as though it was their religion. There are heated debates with people on both sides having strong and uncompromising opinions. Often these debates are filled with FUD (Fear, Uncertainty, Doubt), and illogical accusations. Windows vs. Linux is another "religious argument"
Nathan Koop
I know what a religious argument is :) I was just wondering what the argument was about exactly. Supposed solutions to the mismatch problem? If so, what solutions?
Rik
@Rik: You mentioned impedance mismatch in your later answer and then an article using the Vietname war as an example. I used religion: you used a cold war analogy.
gbn
You mean the mismatch *itself* is a religious argument? In the sense that there won't be an all-round excepted solution to it? Religious arguments in programming are usually concerned which piece of technology is "better", so I was a bit confused.
Rik
No, I mean religious because each technique is deemed superior to the other by many, er, disciples. There are side arguements too such as using stored procs or not, which is related. I've had this kind of discussions with my Java OO propellor head collagues :-)
gbn
A: 

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.

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.

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.

John Nolan
+3  A: 

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.

Rik