<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><span class=""><div class=""><br class=""></div></span>Well, if you’re going to apply SQL to JSON (say), then the first thing you have to do is define a mapping from JSON to tables. That’s not difficult to do.</div><div class=""><br class=""></div><div class="">If by the “closure property” you want the result of any SQL query to be the representation of some JSON structure, then you’re not going to achieve that. That’s essentially the same as the update problem.</div><div class=""><br class=""></div></div></blockquote><div class=""><br class=""></div><div class="">So pretty much no  subqueries (ok somebody is going to say that any query entailing a subquery can be rewritten without one) but AFAIC  the language you are talking about isn't really SQL then. </div></div></div></div></div></blockquote><div><br class=""></div><div>I don’t follow. You can write any query you like; it’s just that the result is a table that might not be mappable back to JSON.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><span class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div></div></div></blockquote></span></div></div></blockquote><div class="">So I'm SOL if it's a date then. </div></div></div></div></div></blockquote><div><br class=""></div>You won’t get any dates in the table representation of JSON, but you can get them in tables returned by a query.<br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><span class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""></div><div class=""><br class=""></div></div></div></blockquote></span></div></div></blockquote><div class="">Forgive me if I'm wrong. But I still don't believe I can write a statement that gets me the 5th row of the table.</div></div></div></div></div></blockquote><div><br class=""></div><div>Well, a typical representation of a JSON array [“a”, “b”, “c”] might be the table</div><div><br class=""></div><div>ARRAYS</div><div>ID       INDEX    TYPE   VALUE</div><div>001     0             String   “a”</div><div>001     1             String   “b”</div><div>001     2             String   “c”</div><div><br class=""></div><div>and the query to get item 2 of array 001 would be</div><div><br class=""></div><div>SELECT TYPE, VALUE FROM ARRAYS WHERE ID=001 AND INDEX=2</div><div><br class=""></div><div>As far as I understand it this is similar to the mapping that SQL Server uses for XML.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><div class=""><br class=""></div><div class="">How would you  predict a priori what your table and column names would be and how many of them. </div></div></div></div></div></blockquote><div><br class=""></div><div>If you’ve got no schema then you have to use a generic mapping in which the table and column names are generic concepts such as ARRAY, MAP, etc.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class=""><br class=""></div><div class="">If you don't can't predict the schema your semi-structured is going to generate then  how could you write your query. </div></div></div></div></blockquote><br class=""></div><div>With difficulty. I can’t see anyone wanting to write it by hand.</div><div><br class=""></div><div>Michael Kay</div><div>Saxonica</div></body></html>