<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: PUT is not UPDATE</title>
	<atom:link href="http://cafe.elharo.com/web/put-is-not-update/feed/" rel="self" type="application/rss+xml" />
	<link>http://cafe.elharo.com/web/put-is-not-update/</link>
	<description>Longer than a blog; shorter than a book</description>
	<pubDate>Sun, 12 Oct 2008 05:13:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Meble</title>
		<link>http://cafe.elharo.com/web/put-is-not-update/#comment-134783</link>
		<dc:creator>Meble</dc:creator>
		<pubDate>Sat, 29 Sep 2007 14:00:16 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/web/put-is-not-update/#comment-134783</guid>
		<description>Iâ€™m pleased people are at least talking about how to use HTTP properly, even if we get it wrong sometimes. Just think how much further weâ€™d be down this road if we spent as much time on it as has been spent on WS-* and SOAP.</description>
		<content:encoded><![CDATA[<p>Iâ€™m pleased people are at least talking about how to use HTTP properly, even if we get it wrong sometimes. Just think how much further weâ€™d be down this road if we spent as much time on it as has been spent on WS-* and SOAP.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Downey &#187; Blog Archive &#187; A New Resource, Please</title>
		<link>http://cafe.elharo.com/web/put-is-not-update/#comment-70494</link>
		<dc:creator>Paul Downey &#187; Blog Archive &#187; A New Resource, Please</dc:creator>
		<pubDate>Sat, 31 Mar 2007 07:17:49 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/web/put-is-not-update/#comment-70494</guid>
		<description>[...] Other people disagree, but the most convincing comments against my preference come from an optimistic Paul. [...]</description>
		<content:encoded><![CDATA[<p>[...] Other people disagree, but the most convincing comments against my preference come from an optimistic Paul. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Keane</title>
		<link>http://cafe.elharo.com/web/put-is-not-update/#comment-68016</link>
		<dc:creator>Peter Keane</dc:creator>
		<pubDate>Sat, 24 Mar 2007 06:11:43 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/web/put-is-not-update/#comment-68016</guid>
		<description>While we are throwing SQL analogies around, one that I have found quite useful is to think of POST as 'get next insert id' (Postgres users may appreciate the need for this -- MySQL users are generally content w/ auto-increment ids and don't need to think about things like sequence generators).  

To add a new resource, I 'POST' to the collection url and get back a unique identifier.  I can use it then and there to 'PUT' a resource OR I can forget about it -- the server agrees to never hand out that same ID again -- whether it actually creates the 'empty' resource a that ID or not can be an implementation detail (it may be useful to have a return code other than 404 in response to a GET on that id -- something that says 'no resource at this ID, but it has already been claimed').   So implementing POST on the server is pretty simple....

Any thoughts on that?</description>
		<content:encoded><![CDATA[<p>While we are throwing SQL analogies around, one that I have found quite useful is to think of POST as &#8216;get next insert id&#8217; (Postgres users may appreciate the need for this &#8212; MySQL users are generally content w/ auto-increment ids and don&#8217;t need to think about things like sequence generators).  </p>
<p>To add a new resource, I &#8216;POST&#8217; to the collection url and get back a unique identifier.  I can use it then and there to &#8216;PUT&#8217; a resource OR I can forget about it &#8212; the server agrees to never hand out that same ID again &#8212; whether it actually creates the &#8216;empty&#8217; resource a that ID or not can be an implementation detail (it may be useful to have a return code other than 404 in response to a GET on that id &#8212; something that says &#8216;no resource at this ID, but it has already been claimed&#8217;).   So implementing POST on the server is pretty simple&#8230;.</p>
<p>Any thoughts on that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Taft</title>
		<link>http://cafe.elharo.com/web/put-is-not-update/#comment-67639</link>
		<dc:creator>Adam Taft</dc:creator>
		<pubDate>Thu, 22 Mar 2007 23:37:51 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/web/put-is-not-update/#comment-67639</guid>
		<description>&lt;blockquote&gt;
Elias Torres Says:
â€¦ and thereâ€™s always PATCH.
&lt;/blockquote&gt;

No there's not.  You're reading a DRAFT of the HTTP/1.1 spec.  The FINAL spec does not include PATCH or many of the other (arguably useful) methods in it (like COPY, MOVE, etc. though these are in Webdav to a certain extent).

http://www.w3.org/Protocols/rfc2616/rfc2616.html</description>
		<content:encoded><![CDATA[<blockquote><p>
Elias Torres Says:<br />
â€¦ and thereâ€™s always PATCH.
</p></blockquote>
<p>No there&#8217;s not.  You&#8217;re reading a DRAFT of the HTTP/1.1 spec.  The FINAL spec does not include PATCH or many of the other (arguably useful) methods in it (like COPY, MOVE, etc. though these are in Webdav to a certain extent).</p>
<p><a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html" rel="nofollow">http://www.w3.org/Protocols/rfc2616/rfc2616.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Marks</title>
		<link>http://cafe.elharo.com/web/put-is-not-update/#comment-66287</link>
		<dc:creator>Kevin Marks</dc:creator>
		<pubDate>Sun, 18 Mar 2007 10:37:44 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/web/put-is-not-update/#comment-66287</guid>
		<description>&lt;blockquote&gt;The only thing you can do in HTTP is send the entire resource again, to completely replace the existing resource. Thereâ€™s really no equivalent in SQL, but if you must have one, then PUT is like a DELETE, followed by an INSERT, using the same primary key.&lt;/blockquote&gt;
There is an equivalent in MySQL called REPLACE, which does exactly that (and is not recommended because of the index churn it causes).</description>
		<content:encoded><![CDATA[<blockquote><p>The only thing you can do in HTTP is send the entire resource again, to completely replace the existing resource. Thereâ€™s really no equivalent in SQL, but if you must have one, then PUT is like a DELETE, followed by an INSERT, using the same primary key.</p></blockquote>
<p>There is an equivalent in MySQL called REPLACE, which does exactly that (and is not recommended because of the index churn it causes).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://cafe.elharo.com/web/put-is-not-update/#comment-65549</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Fri, 16 Mar 2007 14:07:40 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/web/put-is-not-update/#comment-65549</guid>
		<description>Yes, HTTP's PUT is not SQL's UPDATE.  But, it certainly is CRUD's UPDATE.  Read it here (pages 54 and 55):  HTTP 1.1: http://www.ietf.org/rfc/rfc2616.txt</description>
		<content:encoded><![CDATA[<p>Yes, HTTP&#8217;s PUT is not SQL&#8217;s UPDATE.  But, it certainly is CRUD&#8217;s UPDATE.  Read it here (pages 54 and 55):  HTTP 1.1: <a href="http://www.ietf.org/rfc/rfc2616.txt" rel="nofollow">http://www.ietf.org/rfc/rfc2616.txt</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://cafe.elharo.com/web/put-is-not-update/#comment-65244</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Thu, 15 Mar 2007 09:08:02 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/web/put-is-not-update/#comment-65244</guid>
		<description>As Hans stated, the biggest point of confusion here is trying to draw a direct correlation between HTTP methods and a RDBMS. It's naive to always map a single URI to a single entity an a database. You could have a resource in a URI that is made up of several tables in the database, as the concepts in your application may exceed the concepts of your database (think DDD).

Partial updates are also important for high transactional web apps. Often times you only want to update select columns in a table, as some may rarely if ever change, or changing them could cause index updates and other side effects that could be avoided. I've worked on enough projects where always trying to update everything can cause contention and other nasties in the database.

HTTP methods should be used in the context of the resources they're being applied to, as the RFC is not a panacea</description>
		<content:encoded><![CDATA[<p>As Hans stated, the biggest point of confusion here is trying to draw a direct correlation between HTTP methods and a RDBMS. It&#8217;s naive to always map a single URI to a single entity an a database. You could have a resource in a URI that is made up of several tables in the database, as the concepts in your application may exceed the concepts of your database (think DDD).</p>
<p>Partial updates are also important for high transactional web apps. Often times you only want to update select columns in a table, as some may rarely if ever change, or changing them could cause index updates and other side effects that could be avoided. I&#8217;ve worked on enough projects where always trying to update everything can cause contention and other nasties in the database.</p>
<p>HTTP methods should be used in the context of the resources they&#8217;re being applied to, as the RFC is not a panacea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bert Lamb &#187; links for 2007-03-13</title>
		<link>http://cafe.elharo.com/web/put-is-not-update/#comment-64678</link>
		<dc:creator>Bert Lamb &#187; links for 2007-03-13</dc:creator>
		<pubDate>Tue, 13 Mar 2007 09:18:44 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/web/put-is-not-update/#comment-64678</guid>
		<description>[...] The Cafes Â» PUT is not UPDATE (tags: rest WebServices) [...]</description>
		<content:encoded><![CDATA[<p>[...] The Cafes Â» PUT is not UPDATE (tags: rest WebServices) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Schinkel</title>
		<link>http://cafe.elharo.com/web/put-is-not-update/#comment-64646</link>
		<dc:creator>Mike Schinkel</dc:creator>
		<pubDate>Tue, 13 Mar 2007 05:45:02 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/web/put-is-not-update/#comment-64646</guid>
		<description>Rusty: You are right that (HTTP) PUT isn't (SQL) UPDATE, but not in the way you are suggesting. PUT isn't UPDATE because PUT is a subset of UPDATE as HTTP doesn't have the functionality that UPDATE has. UPDATE can update multiple end points, PUT can only update one. Using SQL sytntax to put a new delivery date to invoice #12345 at api.example.com (NOTE there is no need for a WHERE clause):

   UPDATE api.example.com
   SET [/invoices/12345/delivery-date/] = '2007-03-15'

What HTTP can't do is update more than one 'record' (resource) which is why the WHERE clause is not needed.

Of course you could argue that HTTP PUT has more power than SQL UPDATE because most SQL implementations cannot do this. Here's my TSQL psuedo-code showing the ability to declare an "invoice resource":

	DECLARE @Inv12345 AS 'invoice-resource'
	EXEC prc_GetInvoice @InvoiceNo= 12345, @invoice= @Inv12345 OUT
	UPDATE api.example.com
	SET [/invoices/12345/] = @Inv12345

However, with the ability to store JSON in TEXT fields or XML is XML fields, SQL *can* do that (well, you can't index into JSON and update portions of a JSON resource using SQL like you can on many servers with XML and XPATH.)</description>
		<content:encoded><![CDATA[<p>Rusty: You are right that (HTTP) PUT isn&#8217;t (SQL) UPDATE, but not in the way you are suggesting. PUT isn&#8217;t UPDATE because PUT is a subset of UPDATE as HTTP doesn&#8217;t have the functionality that UPDATE has. UPDATE can update multiple end points, PUT can only update one. Using SQL sytntax to put a new delivery date to invoice #12345 at api.example.com (NOTE there is no need for a WHERE clause):</p>
<p>   UPDATE api.example.com<br />
   SET [/invoices/12345/delivery-date/] = &#8216;2007-03-15&#8242;</p>
<p>What HTTP can&#8217;t do is update more than one &#8216;record&#8217; (resource) which is why the WHERE clause is not needed.</p>
<p>Of course you could argue that HTTP PUT has more power than SQL UPDATE because most SQL implementations cannot do this. Here&#8217;s my TSQL psuedo-code showing the ability to declare an &#8220;invoice resource&#8221;:</p>
<p>	DECLARE @Inv12345 AS &#8216;invoice-resource&#8217;<br />
	EXEC prc_GetInvoice @InvoiceNo= 12345, @invoice= @Inv12345 OUT<br />
	UPDATE api.example.com<br />
	SET [/invoices/12345/] = @Inv12345</p>
<p>However, with the ability to store JSON in TEXT fields or XML is XML fields, SQL *can* do that (well, you can&#8217;t index into JSON and update portions of a JSON resource using SQL like you can on many servers with XML and XPATH.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ocean</title>
		<link>http://cafe.elharo.com/web/put-is-not-update/#comment-64577</link>
		<dc:creator>ocean</dc:creator>
		<pubDate>Mon, 12 Mar 2007 21:28:20 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/web/put-is-not-update/#comment-64577</guid>
		<description>I don't think this is true. The payload of a PUT request is a representation of the resource. The server is then allowed to interpret this representation in any way it wants as long it respects the logical 'replace that with this' constraint on PUT. So it'd be perfectly fine to submit a 'partial' representation in a PUT it just might not be 100% kosher.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think this is true. The payload of a PUT request is a representation of the resource. The server is then allowed to interpret this representation in any way it wants as long it respects the logical &#8216;replace that with this&#8217; constraint on PUT. So it&#8217;d be perfectly fine to submit a &#8216;partial&#8217; representation in a PUT it just might not be 100% kosher.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
