Comments on: On ORMs and "Impedence Mismatch" http://thoughts.davisjeff.com/2007/12/03/on-orms-and-impedence-mismatch/ Ideas on Databases, Logic, and Language by Jeff Davis Tue, 19 Jun 2012 16:18:51 +0000 hourly 1 http://wordpress.org/?v=3.3.1 By: Why DBMSs are so complex « Experimental Thoughts http://thoughts.davisjeff.com/2007/12/03/on-orms-and-impedence-mismatch/comment-page-1/#comment-25 Why DBMSs are so complex « Experimental Thoughts Wed, 29 Jul 2009 03:13:14 +0000 http://davisjeff.wordpress.com/?p=6#comment-25 [...] (that is, one application instance doesn’t care what another instance is doing). See my previous post for more [...] [...] (that is, one application instance doesn’t care what another instance is doing). See my previous post for more [...]

]]>
By: Jeff Davis http://thoughts.davisjeff.com/2007/12/03/on-orms-and-impedence-mismatch/comment-page-1/#comment-14 Jeff Davis Wed, 23 Apr 2008 04:18:12 +0000 http://davisjeff.wordpress.com/?p=6#comment-14 There's nothing wrong with using a specific ORM as a tool for a specific application. The problems appear when someone tries to use an ORM to solve a general problem. In particular, using an ORM to try to solve the "impedance mismatch" is going to fail. For your application, the question you should be asking is not what's presented to the user, but if the information needs to make sense to other users. If the information does need to make sense to other users, then you should design the database accordingly. If the data only has value to that one user, than an ORM may be safe to use. There’s nothing wrong with using a specific ORM as a tool for a specific application.

The problems appear when someone tries to use an ORM to solve a general problem. In particular, using an ORM to try to solve the “impedance mismatch” is going to fail.

For your application, the question you should be asking is not what’s presented to the user, but if the information needs to make sense to other users. If the information does need to make sense to other users, then you should design the database accordingly. If the data only has value to that one user, than an ORM may be safe to use.

]]>
By: Richard Broersma Jr. http://thoughts.davisjeff.com/2007/12/03/on-orms-and-impedence-mismatch/comment-page-1/#comment-8 Richard Broersma Jr. Tue, 22 Apr 2008 14:36:57 +0000 http://davisjeff.wordpress.com/?p=6#comment-8 Jeff, The first time I read this blog, I only slight understood the concepts that you were mentioning. However, I am in the middle of reading a book "Data Access Patterns: Database Interactions in Object-Oriented Applications." I feel that I have a better understanding of your arguments. Since I feel that my SQL skill are much stronger than my code skills, one of the thoughts that concerned me while reading the book was that implementing a ORM, was that the mind set of the ORM was to process data in singular pieces instead of larger chunks at a time. This would essentially eliminate 90% of the SQL that could be used to replace repetitive time consuming manual tasks in a application. However, would you say that there are certain cases where using an ORM is useful. In my case, I am working towards developing an interface that will allow a user to view and interact with data as represented in the format of a diagram (an instrument loop diagram to be exact). Would using an ORM have any advantage when trying to displays data in a format other than the typical tabular format. back ground: I am playing with implementing Netbean's Visual Library into my application in an effort to display data in a format that engineers understand. Jeff,

The first time I read this blog, I only slight understood the concepts that you were mentioning. However, I am in the middle of reading a book “Data Access Patterns: Database Interactions in Object-Oriented Applications.” I feel that I have a better understanding of your arguments. Since I feel that my SQL skill are much stronger than my code skills, one of the thoughts that concerned me while reading the book was that implementing a ORM, was that the mind set of the ORM was to process data in singular pieces instead of larger chunks at a time. This would essentially eliminate 90% of the SQL that could be used to replace repetitive time consuming manual tasks in a application.

However, would you say that there are certain cases where using an ORM is useful. In my case, I am working towards developing an interface that will allow a user to view and interact with data as represented in the format of a diagram (an instrument loop diagram to be exact). Would using an ORM have any advantage when trying to displays data in a format other than the typical tabular format.

back ground: I am playing with implementing Netbean’s Visual Library into my application in an effort to display data in a format that engineers understand.

]]>
By: Jeff Davis http://thoughts.davisjeff.com/2007/12/03/on-orms-and-impedence-mismatch/comment-page-1/#comment-13 Jeff Davis Tue, 05 Feb 2008 03:42:01 +0000 http://davisjeff.wordpress.com/?p=6#comment-13 "All theses relationships have their counterpart in the relational model with integrity contraints like foreign keys etc" Any information can be expressed in many different structures. However, not all structures are equal. "But the primary key is important to decrease the impedance mismatch" I assume here that you are referring to a surrogate key, that is, a generated number that is visible to the application, but hidden from the user (and hidden from the business overall). I already made the argument that surrogate keys are a bad idea here: http://people.planetpostgresql.org/jdavis/index.php?/archives/4-Terminology-Confusion.html Surrogate keys do nothing to decrease the real impedance mismatch, which I described in this article in detail. For just one instance, how does a surrogate key make the data in an application less context-sensitive? "The transition to 100% object is not yet resolved because of the persistance that needs RDBMS instead of File Systems." Object oriented data structures are essentially graphs (or perhaps trees). Graphs are very difficult to work with compared to relations. Graph data structures have been around longer than relations, and the Relational Model was invented to solve many of the problems created by storing data in graph structures. I think the "transition to 100% object" will never be complete, because I think it's fundamentally a bad idea. Using object-oriented database management systems is a regression. "The bridge between the Application data and a well designed database data is made automatically by tools but sometimes there is some pitfalls." You completely ignored the fundamental differences between application data and database data that I listed in this article. The differences are not avoidable by "tools". “All theses relationships have their counterpart in the relational model with integrity contraints like foreign keys etc”

Any information can be expressed in many different structures. However, not all structures are equal.

“But the primary key is important to decrease the impedance mismatch”

I assume here that you are referring to a surrogate key, that is, a generated number that is visible to the application, but hidden from the user (and hidden from the business overall).

I already made the argument that surrogate keys are a bad idea here:

http://people.planetpostgresql.org/jdavis/index.php?/archives/4-Terminology-Confusion.html

Surrogate keys do nothing to decrease the real impedance mismatch, which I described in this article in detail. For just one instance, how does a surrogate key make the data in an application less context-sensitive?

“The transition to 100% object is not yet resolved because of the persistance that needs RDBMS instead of File Systems.”

Object oriented data structures are essentially graphs (or perhaps trees). Graphs are very difficult to work with compared to relations. Graph data structures have been around longer than relations, and the Relational Model was invented to solve many of the problems created by storing data in graph structures.

I think the “transition to 100% object” will never be complete, because I think it’s fundamentally a bad idea. Using object-oriented database management systems is a regression.

“The bridge between the Application data and a well designed database data is made automatically by tools but sometimes there is some pitfalls.”

You completely ignored the fundamental differences between application data and database data that I listed in this article. The differences are not avoidable by “tools”.

]]>
By: Mohamed ROMDANE http://thoughts.davisjeff.com/2007/12/03/on-orms-and-impedence-mismatch/comment-page-1/#comment-7 Mohamed ROMDANE Mon, 04 Feb 2008 07:05:55 +0000 http://davisjeff.wordpress.com/?p=6#comment-7 A summary of the kinds of relationships between classes in the object model are: 1. Link (1-1, N-1, 1-N, N-M) / +ternary 2. IsA (3 flavours) / Inheritance 3. PartOf (Composition or inner class) All theses relationships have their counterpart in the relational model with integrity contraints like foreign keys etc ... I agree that a Class is not equal to a Table. But the primary key is important to decrease the impedance mismatch in the object world so we have to create an identifier for a class even if the object has its own object identifier which id an address in memory that way the data inserted in the ralational database can be used by tools other parties (business objects, crystal reports, ...) The transition to 100% object is not yet resolved because of the persistance that needs RDBMS instead of File Systems. We can see this in the Entity EJB (BMP and CMP) and now with EJB3. I think that the mapping is now mature but the way to program it is less straightforward. The bridge between the Application data and a well designed database data is made automatically by tools but sometimes there is some pitfalls. Concerning the updates you have to make it from the Object Model and make queries from both parts (Model and relational) to keep data integrity. If we store the entire object we won't use the sql language to make directly join on columns data, so we can make queries only from the object side and not from the relational side. Hope that helps. Mohamed ROMDANE A summary of the kinds of relationships between classes in the object model are:
1. Link (1-1, N-1, 1-N, N-M) / +ternary
2. IsA (3 flavours) / Inheritance
3. PartOf (Composition or inner class)
All theses relationships have their counterpart in the relational model with integrity contraints like foreign keys etc …
I agree that a Class is not equal to a Table.
But the primary key is important to decrease the impedance mismatch in the object world so we have to create an identifier for a class even if the object has its own object identifier which id an address in memory that way the data inserted in the ralational database can be used by tools other parties (business objects, crystal reports, …)
The transition to 100% object is not yet resolved because of the persistance that needs RDBMS instead of File Systems.
We can see this in the Entity EJB (BMP and CMP) and now with EJB3.
I think that the mapping is now mature but the way to program it is less straightforward.
The bridge between the Application data and a well designed database data is made automatically by tools but sometimes there is some pitfalls.
Concerning the updates you have to make it from the Object Model and make queries from both parts (Model and relational) to keep data integrity.
If we store the entire object we won’t use the sql language to make directly join on columns data, so we can make queries only from the object side and not from the relational side.

Hope that helps.

Mohamed ROMDANE

]]>
By: van helsing http://thoughts.davisjeff.com/2007/12/03/on-orms-and-impedence-mismatch/comment-page-1/#comment-10 van helsing Wed, 26 Dec 2007 05:54:21 +0000 http://davisjeff.wordpress.com/?p=6#comment-10 this could save your life: silver bullets work agains werewolves, not vampires. this could save your life: silver bullets work agains werewolves, not vampires.

]]>
By: David Fetter http://thoughts.davisjeff.com/2007/12/03/on-orms-and-impedence-mismatch/comment-page-1/#comment-6 David Fetter Wed, 05 Dec 2007 07:50:33 +0000 http://davisjeff.wordpress.com/?p=6#comment-6 It seems to me that the entire "introspection" piece of ORM systems is based on three assumptions: - Writing SQL by hand is bad. - Mapping SQL to methods by hand is also bad. - Automating the creation of SQL or its mapping to the OO (or other) code saves time or other resources over the scope of the project. In my experience, these are all false. It seems to me that the entire “introspection” piece of ORM systems is
based on three assumptions:

- Writing SQL by hand is bad.

- Mapping SQL to methods by hand is also bad.

- Automating the creation of SQL or its mapping to the OO (or other)
code saves time or other resources over the scope of the project.

In my experience, these are all false.

]]>
By: Jeff Davis http://thoughts.davisjeff.com/2007/12/03/on-orms-and-impedence-mismatch/comment-page-1/#comment-12 Jeff Davis Tue, 04 Dec 2007 05:27:05 +0000 http://davisjeff.wordpress.com/?p=6#comment-12 Interesting idea. I find compile-time type safety between the application and database especially interesting. I think that's a more promising line of research, because it's using the equation "type is analogous to type" not "type is analysis to table (relation variable)". Smoothing over type mismatches would be a great way to encourage people to use an RDBMS correctly. Interesting idea. I find compile-time type safety between the application and database especially interesting.

I think that’s a more promising line of research, because it’s using the equation “type is analogous to type” not “type is analysis to table (relation variable)”. Smoothing over type mismatches would be a great way to encourage people to use an RDBMS correctly.

]]>
By: Jeff Davis http://thoughts.davisjeff.com/2007/12/03/on-orms-and-impedence-mismatch/comment-page-1/#comment-9 Jeff Davis Tue, 04 Dec 2007 05:09:49 +0000 http://davisjeff.wordpress.com/?p=6#comment-9 I don't think academia has completely dropped the ball. See "Databases, Types, and the Relational Model: The Third Manifesto" by CJ Date and Hugh Darwen. The authors propose a database system that supports sophisticated data types, including type inheritance. They reject the "class = table" analogy. Keep in mind that application data and database data are inherently different, for the reasons I list above. OOP and pointers are inherently closer to physical representations, and applications must inherently manipulate physical representations. So, an OOP approach to application design is natural. However, at some point you need to translate that data into something with meaning outside of context and abstracted from physical representation. Relations are a great way to do that, and you absolutely can use complex types in your relations' predicates. Your code doesn't know the meaning of your physical representations of data. That is, a pointer represents a "relationship" between two things, but that is arbitrary and holds little meaning. Only when you transform the physical representation to match a predicate does it have a logical meaning from which other code (not just humans) can draw inferences. I don’t think academia has completely dropped the ball. See “Databases, Types, and the Relational Model: The Third Manifesto” by CJ Date and Hugh Darwen.

The authors propose a database system that supports sophisticated data types, including type inheritance. They reject the “class = table” analogy.

Keep in mind that application data and database data are inherently different, for the reasons I list above. OOP and pointers are inherently closer to physical representations, and applications must inherently manipulate physical representations. So, an OOP approach to application design is natural.

However, at some point you need to translate that data into something with meaning outside of context and abstracted from physical representation. Relations are a great way to do that, and you absolutely can use complex types in your relations’ predicates.

Your code doesn’t know the meaning of your physical representations of data. That is, a pointer represents a “relationship” between two things, but that is arbitrary and holds little meaning. Only when you transform the physical representation to match a predicate does it have a logical meaning from which other code (not just humans) can draw inferences.

]]>
By: Jonathan Gardner http://thoughts.davisjeff.com/2007/12/03/on-orms-and-impedence-mismatch/comment-page-1/#comment-5 Jonathan Gardner Tue, 04 Dec 2007 04:22:01 +0000 http://davisjeff.wordpress.com/?p=6#comment-5 For me, growing up as a software developer back when perl's DBI was in vogue, I have never seen the point of mapping tables to classes, except as a tool to make accessing and aggregating that data more efficient in the code. I guess you have summarized what I have been feeling ever since I was introduced to the idea of an ORM. Too many people take the O's that the ORM gives you and treat them like first-class application objects when they are really a portal to the database world, a world that lives under different rules and assumptions than the application. For me, growing up as a software developer back when perl’s DBI was in vogue, I have never seen the point of mapping tables to classes, except as a tool to make accessing and aggregating that data more efficient in the code. I guess you have summarized what I have been feeling ever since I was introduced to the idea of an ORM. Too many people take the O’s that the ORM gives you and treat them like first-class application objects when they are really a portal to the database world, a world that lives under different rules and assumptions than the application.

]]>