<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: RESTful SQL?</title>
	<link>http://dowhatimean.net/2006/11/restful-sql</link>
	<description>Richard Cyganiak's Weblog</description>
	<pubDate>Mon, 13 Oct 2008 15:34:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: Richard Cyganiak</title>
		<link>http://dowhatimean.net/2006/11/restful-sql#comment-16043</link>
		<dc:creator>Richard Cyganiak</dc:creator>
		<pubDate>Thu, 23 Nov 2006 21:53:45 +0000</pubDate>
		<guid>http://dowhatimean.net/2006/11/restful-sql#comment-16043</guid>
		<description>&lt;p&gt;Thanks Mark, I think I understand your point about what to do over HTTP and what not, though I do not agree. My POV is that clearly, when your problem maps nicely into REST, then use REST, but some problems don&#8217;t, and in that case tunneling over HTTP might still be the best approach because it gives at least &lt;em&gt;some&lt;/em&gt; of the benefits.&lt;/p&gt;

&lt;p&gt;I still wonder about my POST approach a few posts up. It has the “query URI” to identify just the subset of data we want to update, but then POSTs to the URI in order to avoid the expense of having to pull all the data over the wire, increment it client-side, and push it back up. Basically it maps things nicely into resources as Stelios suggested, but allows POST with an expression language to change resources. What do you think about that?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks Mark, I think I understand your point about what to do over HTTP and what not, though I do not agree. My POV is that clearly, when your problem maps nicely into REST, then use REST, but some problems don&#8217;t, and in that case tunneling over HTTP might still be the best approach because it gives at least <em>some</em> of the benefits.</p>

<p>I still wonder about my POST approach a few posts up. It has the “query URI” to identify just the subset of data we want to update, but then POSTs to the URI in order to avoid the expense of having to pull all the data over the wire, increment it client-side, and push it back up. Basically it maps things nicely into resources as Stelios suggested, but allows POST with an expression language to change resources. What do you think about that?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Baker</title>
		<link>http://dowhatimean.net/2006/11/restful-sql#comment-16041</link>
		<dc:creator>Mark Baker</dc:creator>
		<pubDate>Thu, 23 Nov 2006 21:15:32 +0000</pubDate>
		<guid>http://dowhatimean.net/2006/11/restful-sql#comment-16041</guid>
		<description>&lt;p&gt;Erm, yah, what Stelios said (in his last 2 messages). 8-)  I should have read all the comments first.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Erm, yah, what Stelios said (in his last 2 messages). 8-)  I should have read all the comments first.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Baker</title>
		<link>http://dowhatimean.net/2006/11/restful-sql#comment-16040</link>
		<dc:creator>Mark Baker</dc:creator>
		<pubDate>Thu, 23 Nov 2006 21:13:20 +0000</pubDate>
		<guid>http://dowhatimean.net/2006/11/restful-sql#comment-16040</guid>
		<description>&lt;p&gt;Richard - not everything not RESTful is not part of the Web (got that? 8-).  Cookies are a great example, as you point out.  But IMO, none of the other examples you provided are, and none should be using port 80.&lt;/p&gt;

&lt;p&gt;I won&#8217;t elaborate much more on the caching point.  You really have to implement it.  Suffice to say that it&#8217;s really not that difficult at all to keep state changes local.  And where it isn&#8217;t, just turn off caching.  But be wary of models or conventions which require turning it off.&lt;/p&gt;

&lt;p&gt;To do the equivalent of your UPDATE example (btw, your SQL could use some work 8-) RESTfully - and I mentioned this on my weblog comments in the context of a similar example - the server could offer a GET form that the client could first populate with &#8220;500&#8243; (addressing the &#62;500 requirement), creating a new &#8220;query URI&#8221; (ala HTML forms) upon which GET would return a document representing all the foo values.  Then the client would do the &#8220;+1&#8243; and PUT it back to the server.  Voila!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Richard - not everything not RESTful is not part of the Web (got that? 8-).  Cookies are a great example, as you point out.  But IMO, none of the other examples you provided are, and none should be using port 80.</p>

<p>I won&#8217;t elaborate much more on the caching point.  You really have to implement it.  Suffice to say that it&#8217;s really not that difficult at all to keep state changes local.  And where it isn&#8217;t, just turn off caching.  But be wary of models or conventions which require turning it off.</p>

<p>To do the equivalent of your UPDATE example (btw, your SQL could use some work 8-) RESTfully - and I mentioned this on my weblog comments in the context of a similar example - the server could offer a GET form that the client could first populate with &#8220;500&#8243; (addressing the &gt;500 requirement), creating a new &#8220;query URI&#8221; (ala HTML forms) upon which GET would return a document representing all the foo values.  Then the client would do the &#8220;+1&#8243; and PUT it back to the server.  Voila!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Stelios Sfakianakis</title>
		<link>http://dowhatimean.net/2006/11/restful-sql#comment-16030</link>
		<dc:creator>Stelios Sfakianakis</dc:creator>
		<pubDate>Thu, 23 Nov 2006 18:27:27 +0000</pubDate>
		<guid>http://dowhatimean.net/2006/11/restful-sql#comment-16030</guid>
		<description>&lt;p&gt;Richard,&lt;/p&gt;

&lt;p&gt;what you propose is to have the operation in the body of the HTTP message in some sort of tunneling which is not RESTful (REST has a standard number of operation that for HTTP are GET,POST,HEAD,DELETE,PUT) but let&#8217;s see what Mark has to say on the subject :-)&lt;/p&gt;

&lt;p&gt;Stelios&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Richard,</p>

<p>what you propose is to have the operation in the body of the HTTP message in some sort of tunneling which is not RESTful (REST has a standard number of operation that for HTTP are GET,POST,HEAD,DELETE,PUT) but let&#8217;s see what Mark has to say on the subject :-)</p>

<p>Stelios</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Cyganiak</title>
		<link>http://dowhatimean.net/2006/11/restful-sql#comment-16023</link>
		<dc:creator>Richard Cyganiak</dc:creator>
		<pubDate>Thu, 23 Nov 2006 17:17:22 +0000</pubDate>
		<guid>http://dowhatimean.net/2006/11/restful-sql#comment-16023</guid>
		<description>&lt;p&gt;Apologies Stelios, I jumped to conclusions. Now I understand the approach, and it looks pretty good.&lt;/p&gt;

&lt;p&gt;I think I&#8217;d like to do it a little bit differently, to avoid having to transfer all the data back and forth. Something like&lt;/p&gt;

&lt;p&gt;POST /codd/table?bar&gt;=500&lt;/p&gt;

&lt;p&gt;and then in the message body the operation to apply to every row:&lt;/p&gt;

&lt;p&gt;foo = foo + 1&lt;/p&gt;

&lt;p&gt;This would map quite nicely to SQL:&lt;/p&gt;

&lt;p&gt;UPDATE table SET foo = foo + 1 WHERE bar&gt;=500&lt;/p&gt;

&lt;p&gt;I wonder what Mark thinks about this.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Apologies Stelios, I jumped to conclusions. Now I understand the approach, and it looks pretty good.</p>

<p>I think I&#8217;d like to do it a little bit differently, to avoid having to transfer all the data back and forth. Something like</p>

<p>POST /codd/table?bar>=500</p>

<p>and then in the message body the operation to apply to every row:</p>

<p>foo = foo + 1</p>

<p>This would map quite nicely to SQL:</p>

<p>UPDATE table SET foo = foo + 1 WHERE bar>=500</p>

<p>I wonder what Mark thinks about this.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Stelios Sfakianakis</title>
		<link>http://dowhatimean.net/2006/11/restful-sql#comment-16021</link>
		<dc:creator>Stelios Sfakianakis</dc:creator>
		<pubDate>Thu, 23 Nov 2006 15:25:24 +0000</pubDate>
		<guid>http://dowhatimean.net/2006/11/restful-sql#comment-16021</guid>
		<description>&lt;p&gt;Richard,&lt;/p&gt;

&lt;p&gt;there is no need to have 2000 round trips to update 1000 rows. In my example GET /codd/table?bar=&#62;500/foo could return a list of (ID, foo-value) pairs, in other words a 2-ary relation. (Actually it couldn&#8217;t have been otherwise because the URI does not uniquely identify a row in the table). Now the client could update all the foo values, reconstruct the list, and PUT it in the server. (Etag/If-Match conditional update is more difficult in this case but it&#8217;s certainly doable&#8230;)&lt;/p&gt;

&lt;p&gt;So the update process is:&lt;/p&gt;

&lt;p&gt;fs = GET /codd/table?bar=&#62;500/foo&lt;/p&gt;

&lt;p&gt;fun = function(id, foo-value) { return (id, ++foo-value);}
fs&#8217; = map fun fs&lt;/p&gt;

&lt;p&gt;PUT /codd/table?bar=&#62;500/foo
fs&#8217;&lt;/p&gt;

&lt;p&gt;:-D&lt;/p&gt;

&lt;p&gt;Stelios&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Richard,</p>

<p>there is no need to have 2000 round trips to update 1000 rows. In my example GET /codd/table?bar=&gt;500/foo could return a list of (ID, foo-value) pairs, in other words a 2-ary relation. (Actually it couldn&#8217;t have been otherwise because the URI does not uniquely identify a row in the table). Now the client could update all the foo values, reconstruct the list, and PUT it in the server. (Etag/If-Match conditional update is more difficult in this case but it&#8217;s certainly doable&#8230;)</p>

<p>So the update process is:</p>

<p>fs = GET /codd/table?bar=&gt;500/foo</p>

<p>fun = function(id, foo-value) { return (id, ++foo-value);}
fs&#8217; = map fun fs</p>

<p>PUT /codd/table?bar=&gt;500/foo
fs&#8217;</p>

<p>:-D</p>

<p>Stelios</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Cyganiak</title>
		<link>http://dowhatimean.net/2006/11/restful-sql#comment-16017</link>
		<dc:creator>Richard Cyganiak</dc:creator>
		<pubDate>Thu, 23 Nov 2006 14:18:12 +0000</pubDate>
		<guid>http://dowhatimean.net/2006/11/restful-sql#comment-16017</guid>
		<description>&lt;p&gt;Thanks all for the thoughtful comments.&lt;/p&gt;

&lt;p&gt;Mark, your first comment seems to say that anything not RESTful is not the Web. Web services and SPARQL HTTP bindings and SQL queries sent via POST requests are certainly not RESTful, but that doesn&#8217;t necessarily make them unappropriate for the Web. 99% of deployed Web content is not RESTful, and most of it works anyway (think cookies).&lt;/p&gt;

&lt;p&gt;I agree with Alex on the caching point. I don&#8217;t believe that many real-world systems can be partitioned in a way that a change to one resource never changes the representations of another resource.&lt;/p&gt;

&lt;p&gt;Stelios&#8217; proposal is nice, unless you want to do something that does not cleanly map to a single resource, like my UPDATE example. It requires 2000 roundtrips to update 1000 rows, where a simple “send SQL via POST” approach would require one roundtrip to do the same. Same for RESTQL, which otherwise is an interesting idea.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks all for the thoughtful comments.</p>

<p>Mark, your first comment seems to say that anything not RESTful is not the Web. Web services and SPARQL HTTP bindings and SQL queries sent via POST requests are certainly not RESTful, but that doesn&#8217;t necessarily make them unappropriate for the Web. 99% of deployed Web content is not RESTful, and most of it works anyway (think cookies).</p>

<p>I agree with Alex on the caching point. I don&#8217;t believe that many real-world systems can be partitioned in a way that a change to one resource never changes the representations of another resource.</p>

<p>Stelios&#8217; proposal is nice, unless you want to do something that does not cleanly map to a single resource, like my UPDATE example. It requires 2000 roundtrips to update 1000 rows, where a simple “send SQL via POST” approach would require one roundtrip to do the same. Same for RESTQL, which otherwise is an interesting idea.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Stelios Sfakianakis</title>
		<link>http://dowhatimean.net/2006/11/restful-sql#comment-16009</link>
		<dc:creator>Stelios Sfakianakis</dc:creator>
		<pubDate>Thu, 23 Nov 2006 10:50:05 +0000</pubDate>
		<guid>http://dowhatimean.net/2006/11/restful-sql#comment-16009</guid>
		<description>&lt;p&gt;Just a clarification for Mark: This was only an attempt to &#8220;RESTify SQL&#8221; and in particular the specific query that Richard posed, trying to be as closer as we can to the original SQL statement. I didn&#8217;t say that this is a recommended way to access a relational database through the web for all the reasons you gave (although I think Alex has a point also). In fact I would say that in many cases the representation of a single tuple (row) of a table as a REST resource is wrong because of the restrictions imposed by the relational model and the normalization of the database (e.g. every attribute has to have a single value). So for example a person&#8217;s addresses (or foaf:mbox&#8217;s :-) could be stored in another table whereas logically belong to the same person entity.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Just a clarification for Mark: This was only an attempt to &#8220;RESTify SQL&#8221; and in particular the specific query that Richard posed, trying to be as closer as we can to the original SQL statement. I didn&#8217;t say that this is a recommended way to access a relational database through the web for all the reasons you gave (although I think Alex has a point also). In fact I would say that in many cases the representation of a single tuple (row) of a table as a REST resource is wrong because of the restrictions imposed by the relational model and the normalization of the database (e.g. every attribute has to have a single value). So for example a person&#8217;s addresses (or foaf:mbox&#8217;s :-) could be stored in another table whereas logically belong to the same person entity.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Luke Opperman</title>
		<link>http://dowhatimean.net/2006/11/restful-sql#comment-16001</link>
		<dc:creator>Luke Opperman</dc:creator>
		<pubDate>Thu, 23 Nov 2006 04:56:36 +0000</pubDate>
		<guid>http://dowhatimean.net/2006/11/restful-sql#comment-16001</guid>
		<description>&lt;p&gt;I&#8217;ll put these thoughts more together later, but here&#8217;s the essence of my reaction:&lt;/p&gt;

&lt;p&gt;This is about distributed data computing. This is about efficient and non-trivial client-specified adhoc querying via http, and local processing for arbitrary-sourced combinations, and probably local processing of relative updates as in this case.&lt;/p&gt;

&lt;p&gt;This is about scaling through applying this distributed-store/local-processing internally in partitioning our data stores. This is about dealing with caching by strong support in the &#8220;physical&#8221; model, not by impinging on the logical layer.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;ll put these thoughts more together later, but here&#8217;s the essence of my reaction:</p>

<p>This is about distributed data computing. This is about efficient and non-trivial client-specified adhoc querying via http, and local processing for arbitrary-sourced combinations, and probably local processing of relative updates as in this case.</p>

<p>This is about scaling through applying this distributed-store/local-processing internally in partitioning our data stores. This is about dealing with caching by strong support in the &#8220;physical&#8221; model, not by impinging on the logical layer.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Alex James</title>
		<link>http://dowhatimean.net/2006/11/restful-sql#comment-15999</link>
		<dc:creator>Alex James</dc:creator>
		<pubDate>Thu, 23 Nov 2006 04:36:46 +0000</pubDate>
		<guid>http://dowhatimean.net/2006/11/restful-sql#comment-15999</guid>
		<description>&lt;p&gt;I don&#8217;t buy the Cache argument I&#8217;m afraid. &lt;/p&gt;

&lt;p&gt;It implies all updates are occuring only through HTTP? how practical is that in reality?&lt;/p&gt;

&lt;p&gt;If I have an application running inside AMAZON&#8217;s network that applies some general discounting rules then all cached URI&#8217;s that represent books are immediately out of date anyway?&lt;/p&gt;

&lt;p&gt;It is not as if because we expose our data restfully, all of a sudden that is going to be the only way you can update it. &lt;/p&gt;

&lt;p&gt;So I don&#8217;t see why you should enforce some rules about PUT granularity in your REST implementation, it makes no sense to me.&lt;/p&gt;

&lt;p&gt;I also don&#8217;t buy the HTTP swamping argument either. Updates are generally a lot less frequent than gets, so why not go granular on the update. If you have a number of tuples to update sure go more chunky, that is a standard piece of distributed architecture advice, but if you have only one thing to update, why pass everything else? &lt;/p&gt;

&lt;p&gt;That can have some nasty side effects too, you might now introduce the last update problem, because of optimistic concurrency issues, i.e. the server doesn&#8217;t actually know what fields you are trying to update so it assumes you are trying to update everything. &lt;/p&gt;

&lt;p&gt;If in our distributed systems we mandate chunkyness we simply further increase the systems brittleness.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I don&#8217;t buy the Cache argument I&#8217;m afraid. </p>

<p>It implies all updates are occuring only through HTTP? how practical is that in reality?</p>

<p>If I have an application running inside AMAZON&#8217;s network that applies some general discounting rules then all cached URI&#8217;s that represent books are immediately out of date anyway?</p>

<p>It is not as if because we expose our data restfully, all of a sudden that is going to be the only way you can update it. </p>

<p>So I don&#8217;t see why you should enforce some rules about PUT granularity in your REST implementation, it makes no sense to me.</p>

<p>I also don&#8217;t buy the HTTP swamping argument either. Updates are generally a lot less frequent than gets, so why not go granular on the update. If you have a number of tuples to update sure go more chunky, that is a standard piece of distributed architecture advice, but if you have only one thing to update, why pass everything else? </p>

<p>That can have some nasty side effects too, you might now introduce the last update problem, because of optimistic concurrency issues, i.e. the server doesn&#8217;t actually know what fields you are trying to update so it assumes you are trying to update everything. </p>

<p>If in our distributed systems we mandate chunkyness we simply further increase the systems brittleness.</p>]]></content:encoded>
	</item>
</channel>
</rss>
