Talk:Object–relational mapping: Difference between revisions

Content deleted Content added
SineBot (talk | contribs)
m Signing comment by 24.7.121.38 - "ObjC version of EOF, where?: "
Implementing WP:PIQA (Task 26)
 
(40 intermediate revisions by 24 users not shown)
Line 1:
{{WikiProject banner shell|class=Start|
{{WikiProject Computing|importance=}}
}}
 
==Introduction==
"This creates, in effect, a "virtual object database" that can be used from within the programming language." I don't think this is the only way for ORM mechanisms/frameworks/tools. Instead, I will say that this is a common implementation for ORM solutions. "Mapping" as relating objects to rows could be solved by creating "hybrid" objects (objects with PK or FK attributes), but also with a real external mapping without changing or mixing ___domain classes with records. [[Special:Contributions/63.128.77.30|63.128.77.30]] ([[User talk:63.128.77.30|talk]]) 17:00, 16 March 2015 (UTC)
 
"technique for converting data between incompatible type systems" sounds like a contradiction in terms. Compatible means two types are able to be converted between, so if they're incompatible, you can't convert between them. <!-- Template:Unsigned IP --><small class="autosigned">—&nbsp;Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/2601:283:4A80:5300:A40A:B4F:1584:3532|2601:283:4A80:5300:A40A:B4F:1584:3532]] ([[User talk:2601:283:4A80:5300:A40A:B4F:1584:3532#top|talk]]) 20:19, 5 April 2022 (UTC)</small> <!--Autosigned by SineBot-->
 
I updated the summary today to try and address some of these concerns. I think the name of the technique gives a solid foundation for an encyclopedic article to explain what these tools do: they map objects to relations. Also, while the title doesn't imply this, in practice with "ORM" people mean that the objects are in a heap, and the relations are in a database. So for a first layer of definition, ORM is automated mapping of objects in a heap, to relations in a database. Then, as a second layer of detail, I listed out the common things that a framework will map at all (lifecycle management, foreign keys, inheritance, contention). I'm sure I missed a few, in that list, but it's a start. I didn't do anything about it, but I think those four things would make excellent subsections of the "Challenges" section later on the page. [[User:Lexspoon|Lexspoon]] ([[User talk:Lexspoon|talk]]) 14:00, 9 January 2023 (UTC)
 
==Relational vs. Non-Relational==
 
SQL isn't relational, and most of the mentions of 'relational' here aren't correct but refer to SQL actually. So I am correcting the article and will move it. [[User:Leandrod|Leandrod]] 19:58, 21 September 2005 (UTC)
: I am sure there is an interesting hair being split here, but in general, "SQL" is the industry standard for accessing "relational" databases, and "ORM" is what this kind of tool is called. I don't know what more to say about the subject without understanding what hair is being split exactly. Is the issue that SQL is a pragmatic real-world language rather than an idealized relational formalism? But ORM tools are also pragmatic real-world tools. Suffice to say I agree with other editors who have changed it all back to "object-relational mapping". [[User:Lexspoon|Lexspoon]] ([[User talk:Lexspoon|talk]]) 13:57, 9 January 2023 (UTC)
 
I don't know what you mean by "SQL isn't relational" SQL is a language designed to act create, modify and select data from relational databases. In any case the whole rest of the world refers to what you've decided to call "Object-SQL mapping" by the term "Object-Relational Mapping" I refer you to the google score of 248 result for "object sql mapping" and 380,000 for "object relational mapping" with similar results with and without a dash. If the article needs to be clarified and improved please do so, but unless I hear back from you or others, I will move this article back to object-relational mapping, which, I strongly believe is where the vast majority of people expect to find it. [[User:Kznf|Charles (Kznf)]] 01:16, 15 October 2005 (UTC)
Line 51 ⟶ 65:
 
There are far too many links. Please limit to only authoritative and well-organized sources. --[[User:Froggienation|Froggienation]] 20:30, 12 February 2007 (UTC)
 
Can we have a list of languages/technologies that utilise this technique? <span style="font-size: smaller;" class="autosigned">—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/79.64.169.41|79.64.169.41]] ([[User talk:79.64.169.41|talk]]) 00:34, 16 April 2009 (UTC)</span><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
 
== Critique ==
 
Line 81 ⟶ 98:
 
:What does "type" mean in this context? It isn't declared in the article. <small>—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/81.207.148.46|81.207.148.46]] ([[User talk:81.207.148.46|talk]]) 08:57, 29 December 2007 (UTC)</small><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
 
"But in general, the pros outweigh the cons when using this paradigm." This statement is a judgment by the author. Pros and cons should be listed, but it's up to the reader to decide whether the pros outweigh cons. <span style="font-size: smaller;" class="autosigned">—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/150.228.40.142|150.228.40.142]] ([[User talk:150.228.40.142|talk]]) 18:34, 9 April 2009 (UTC)</span><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
 
I agree that Wikipedia shouldn't have bald opinions of individual authors. That said, there's a lot of potential encyclopedic content around referring to standard critiques and defenses of ORM. I'll say this non-neutrally on the talk page: having worked for years with ORM tools, I find that they make an easy problem even easier (tedious code to map columns to fields), but then add their own problems that are often really hard and time-consuming to solve (loss of control around locking, reading way more data than you need before making a small edit, reading back data after a save that you usually just throw away anyway, way more complex update commands than if you wrote the SQL by hand), plus the experience of pervasive mystery about what your program is doing. That's on the critique side. I am sure it depends on context, though, and that there are people with good experiences that could provide a defense of these tools. For example, some databases are just used by a single user at a time, in which case a lot of the cons won't really be an issue. [[User:Lexspoon|Lexspoon]] ([[User talk:Lexspoon|talk]]) 14:16, 9 January 2023 (UTC)
 
== New Proposed Article ==
I'd like to propose a new category with corresponding article to catalog all the ORM technologies available in the different languages. It would include Hibernate, NHibernate, SQLAlchemy, ActiveRecord (Rails), etc. --[[User:Kibbled bits|Kibbled bits]] ([[User talk:Kibbled bits|talk]]) 13:55, 3 July 2008 (UTC)
 
== Problem Description ==
 
"However, many popular database products such as SQL DBMS can only store and manipulate scalar values such as integers and strings organized within tables."
This isn't accurate. The major RDBMS products (and the SQL standard) incorporate storing and manipulating object data. See the Wikipedia article on ORDBMS. Also the OODBMS article refers to SQL support in those products. Object persistance is less widley used than the relational model, except in specific domains such as geospatial data where the object definitions are fixed. The rise of ORMs would suggest that the Object/Relational Mapping problem is easier to address than the challenges of persisting object data.
 
== Test Section ==
 
Test Section <span class="autosigned">—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/121.243.32.14|121.243.32.14]] ([[User talk:121.243.32.14|talk]]) 06:49, 16 September 2008 (UTC)</span><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
 
== Dubious ==
 
Most ORM frameworks now should deal with simple joins very well, and even complex ones if following certain templates. The bulk deletions would require custom SQL, and probably are not well done through ORM tools -- [[User:Q Chris|Q Chris]] ([[User talk:Q Chris|talk]]) 15:16, 18 October 2010 (UTC)
 
:Tend to agree. (If Zend Framework can handle joins okay, surely software that ''doesn't suck'' must have gotten it by now.) What would be really awesome is if we had a source saying something about it, of course... &mdash;[[User:Chaos5023|chaos5023]] ([[User talk:Chaos5023|talk]]) 15:24, 18 October 2010 (UTC)
 
::Sourcing it would be good - but so far all I have found are blogs or framework documentation saying that their own framework is good. Both Toplink and Hibernate rate themselves, justifiably by my experience. -- [[User:Q Chris|Q Chris]] ([[User talk:Q Chris|talk]]) 17:38, 18 October 2010 (UTC)
 
== Controversy ==
 
There's not a single citation in this new section and it looks biased and like POV OR to me. The "emerging trend" is that ORM is being banned? Where not, it's being used accompanied by "heavy justification"? If anybody can find a survey that asked CIOs how heavy the justification needs to be for them to allow ORM to be used in their organisations, I'd love to see it. How heavy are we talking here anyway? Like a boulder? An elephant? Maybe a Blue Whale? [[User:Oldernews|Oldernews]] ([[User talk:Oldernews|talk]]) 12:14, 15 December 2010 (UTC)
 
:Agree, its certainly not my experience. -- [[User:Q Chris|Q Chris]] ([[User talk:Q Chris|talk]]) 12:35, 15 December 2010 (UTC)
 
Seems to me that this article is more for those who want to find an alternative to ORM rather than to those who want to know more. <span style="font-size: smaller;" class="autosigned">—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/77.12.17.244|77.12.17.244]] ([[User talk:77.12.17.244|talk]]) 07:40, 2 January 2011 (UTC)</span><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
 
To Dougluce - I think you need better sources than that, "self-published media, such as books, patents, newsletters, personal websites, open wikis,
personal or group blogs, Internet forum postings, and tweets, are largely not acceptable as sources."
From http://en.wikipedia.org/wiki/Wikipedia:Verifiability#Self-published_sources
 
To 86.30.37.126 - ('no citation is needed, it's an inherently true statement, eg 'an alternative wearing shoes is going barefoot')
"An alternative to implementing ORM is use of the native procedural languages provided with every major database on the market. "
This need a source - however 'inherently true' you see it. [[User:Williajm|Williajm]] ([[User talk:Williajm|talk]]) 23:11, 9 February 2011 (UTC)
 
There is currently a lot of heated talk about ORM as an anti pattern due to incorrect abstraction and inefficiency. Right or wrong and I feel some of this controversy should be mentioned. [http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=orm+anti%3Dpattern#sclient=psy&hl=en&safe=off&source=hp&q=orm+anti+pattern&aq=f&aqi=g1&aql=&oq=&pbx=1&bav=on.2,or.r_gc.r_pw.&fp=ce07ae90aca13e82&biw=1440&bih=675] [http://news.ycombinator.com/item?id=2657745]
 
"An alternative to implementing ORM is use of the native procedural languages provided with every major database on the market. " - This should be removed, it is not one of the main alternatives when discussing ORM alternatives. [http://www.mehdi-khalili.com//orm-anti-patterns-series] [http://dumaslab.com/2011/06/orm-is-an-anti-pattern/] <span style="font-size: smaller;" class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/82.21.217.6|82.21.217.6]] ([[User talk:82.21.217.6|talk]]) 07:57, 10 July 2011 (UTC)</span><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
: This section has now twice been deleted (once by me), and twice restored by [[User:Q Chris|Q Chris]].
: This section should go, as it's unrelated to ORM within the scope of this article. It's also barely a referenced section, more of an external link with a caption on it.
: ORM is about mapping between objects within the client and an RDBMS. This section is not - it's about applying OO paradigms to SQL coding, to present an object-like interface at the native SQL call level. This is quite a different thing - the objects are in the RDBMS, not the client. If this approach is used for ORM (which it could be, although it shows no advantage for doing so) it would produce two sets of objects. The style of the ref is also one of those mid-90s "catch up" articles, when old SQL DBA greybeards realised they'd missed out on the last decade on comp sci and they needed to get out and steal some ideas sharpish, if they weren't to be seen as COBOL coders. [[User:Andy Dingley|Andy Dingley]] ([[User talk:Andy Dingley|talk]]) 10:33, 23 August 2011 (UTC)
 
== Abstraction ==
 
Does the use of ORM potentially abstract the use of a particular database - instead becoming potentially an interface to as many database engines as the technology in use potentially supports.
ORMLite for example claims
"Supports MySQL, Postgres, Microsoft SQL Server, H2, Derby, HSQLDB, and Sqlite and can be extended to additional databases relatively easily."
 
I'm not sure if this is true across all ORM technologies. If it is then should this be made clearer in the article as an advantage to ORM? <span style="font-size: smaller;" class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/87.237.64.150|87.237.64.150]] ([[User talk:87.237.64.150|talk]]) 09:34, 12 April 2012 (UTC)</span><!-- Template:Unsigned IP --> <!--Autosigned by SineBot-->
 
Just an observation, but how much of an actual real world advantage is the ability to switch RDBMS without re-coding? Every significant (non-dysfunctional) project I have worked on has defined a single RDBMS at the beginning of the project; either by selecting one or having an incumbent that would take more money to migrate from than the total cost of the planned development. So, in an enterprise development environment (as opposed to an Open source project that may want to support MySQL and PostgreSQL and...) all an ORM gives you is a convenient syntactic sugar to instantiate objects. The cost of this sugar is having the mappings to maintain (instead of the hand-coded object loading code) and being abstracted away from the database. The last thing is a huge hidden cost as in my experience, it encourages developers to not learn how to optimize SQL in their RDBMS. For example, here's a blog post [http://zeroturnaround.com/blog/hibernate-jpa-and-xrebel-continued-understanding-eager-lazy-and-join-fetch-queries-with-an-interactive-profiler/] which describes how to improve Hibernate performance. If the developer had hand-coded the SQL they wouldn't have to spend time digging into why Hibernate was hitting the database 24 times instead of once. Also, when you know a particular dialect of SQL e.g. Oracle you learn more efficient ways of writing SQL that takes advantage of features unique to Oracle. Yes that's vendor lock-in, but in reality most companies do not change RDBMS unless they have a really compelling reason because it is so costly for so little business benefit. Just my 5c <span style="font-size: smaller;" class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/203.161.88.62|203.161.88.62]] ([[User talk:203.161.88.62|talk]]) 05:39, 20 August 2014 (UTC)</span><!-- Template:Unsigned IP --> <!--Autosigned by SineBot-->
 
== What about Micro OR/Ms? ==
 
Would be nice to see some information about those so-called "Micro OR/Ms" that came up within the last 1-2 years, namely Dapper, Massive, PetaPoco and others. <span style="font-size: smaller;" class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/81.14.229.174|81.14.229.174]] ([[User talk:81.14.229.174|talk]]) 17:05, 20 November 2012 (UTC)</span><!-- Template:Unsigned IP --> <!--Autosigned by SineBot-->
 
== Data Mappers ==
 
I've added some information today about Object-Document Mappers and Data Mappers as a general term. These subjects are only related to ORMs and I was unsure if they belonged here - but there is no Data Mapper page on Wikipedia, but perhaps there should be?
 
== Incorrect C# code? ==
 
This example C# line is given as a way to find the person with ID 10:
 
: var person = Person.Get(Person.Properties.Id == 10);
 
However, it looks wrong to me. (Person.Properties.Id == 10) would yield a bool: either true or false. It isn't a lambda or closure or a method that can run to perform a search. [[User:Equinox|Equinox]] [[User_talk:Equinox|◑]] 15:36, 7 March 2023 (UTC)
 
: (Weeks later: I have removed the incorrect code.) [[User:Equinox|Equinox]] [[User_talk:Equinox|◑]] 05:51, 23 March 2023 (UTC)