<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>kill the radio &#187; databases</title>
	<atom:link href="http://blog.killtheradio.net/tag/databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.killtheradio.net</link>
	<description>or die trying</description>
	<lastBuildDate>Thu, 15 Dec 2011 20:21:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>What&#8217;s the point of Object Relational Mapping (ORM)?</title>
		<link>http://blog.killtheradio.net/technology/whats-the-point-of-object-relational-mapping-orm/</link>
		<comments>http://blog.killtheradio.net/technology/whats-the-point-of-object-relational-mapping-orm/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 19:34:04 +0000</pubDate>
		<dc:creator>Andrew Lyon</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[object-oriented]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[procedural]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://blog.killtheradio.net/?p=487</guid>
		<description><![CDATA[In my work as a web developer, I&#8217;ve come across many, many cases where projects, namely projects using PHP frameworks, have made use of an Object Relation Mapping tool. I&#8217;ve used them a bit myself, in apps that use CakePHP. I have to say, after going from writing plain queries to communicating with objects, I [...]]]></description>
			<content:encoded><![CDATA[<p>In my work as a web developer, I&#8217;ve come across many, many cases where projects, namely projects using PHP frameworks, have made use of an Object Relation Mapping tool. I&#8217;ve used them a bit myself, in apps that use <a rel="nofollow" href="http://cakephp.org/">CakePHP</a>. I have to say, after going from writing plain queries to communicating with objects, I prefer very much writing my own queries.</p>
<p>Let&#8217;s first talk about what an <a href="http://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a> is. Basically, you have an app, and you have a database. As the case with most apps, it needs to actually communicate with the database, usually by using queries. Queries are a language the database understands. They allow the application to ask the database for very specific information. An ORM sits between the application and the database. Its role is to give the application an object to communicate to. This object pretends as if it is a piece of data in the database, and allows the app to do things like data.update() or data.delete(). The ORM will write the appropriate queries to the database, regardless of the type of database. A good ORM can also perform joins between pieces of data and perform somewhat complex queries on the database. The purpose is to give a standard interface to communicate with any database.</p>
<p>So here&#8217;s my question: on a simple application, an ORM may be a good idea. It provides a standard interface to communicate with, and also allows the database to be &#8220;easily&#8221; switched out without modifying the main application code at all. But on any app I&#8217;ve worked on, there are many, many queries written that an ORM wouldn&#8217;t be able to map or understand. So what is the point of an ORM if it can&#8217;t handle everything? It&#8217;s a standard interface that becomes non-standard the second you write your first non-ORM query.</p>
<p>There is no way anybody could ever write an ORM that handles every query that possibly needs to be written. And instead of defining relationships between data in your queries, you have to define the relationships through the code.  Also, the argument I hear over and over and over: &#8220;it allows you to switch out your database easily.&#8221; Who the hell switches out their database? Why not just pick a database that does what you want from the beginning&#8230;and for the most part, they all do the same damned thing. Also, SQL is kind-of standard, so even without an ORM it&#8217;s not like you&#8217;ll be rewriting every query from scratch&#8230;most likely you&#8217;ll have to rewrite a few database-specific functions (think SELECT last_insert_id()). Is it really so hard to do this, especially if you only do it once? If you are switching from Oracle to PGSql to MySQL to MSSQL every other day, then yes, an ORM would probably make sense, but otherwise I don&#8217;t see the point.</p>
<p>Data is data, it is not another object. Moving everything under the sun into the object-oriented model does not make anyone&#8217;s life easier. SQL is good. <a href="http://en.wikipedia.org/wiki/Procedural_programming">Procedural</a> is lightning fast. Learn how to use these, because OO will not solve all your problems.</p>
<p>I welcome use-cases besides those I have mentioned and arguments for/against ORMs in the comments. I&#8217;m speaking from personal experience and not married to my opinion&#8230;so I&#8217;m actually very curious if any of you successfully use an ORM that does everything you need it to.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.killtheradio.net/technology/whats-the-point-of-object-relational-mapping-orm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

