简体   繁体   中英

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.

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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