<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 1, 2015 at 3:22 PM, Michael Kay <span dir="ltr"><<a href="mailto:mike@saxonica.com" target="_blank">mike@saxonica.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On 1 Jun 2015, at 19:08, Ihe Onwuka <<a href="mailto:ihe.onwuka@gmail.com" target="_blank">ihe.onwuka@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div>Then I have some questions.</div><div><br></div><div>So what happens to the closure property.</div></div></div></blockquote><div><br></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><br></div><div>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><br></div></div></blockquote><div><br></div><div>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><br></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"><div><span><blockquote type="cite"><div dir="ltr"><div>Should I be allowed to join a JSON array with an object.<br></div></div></blockquote><div><br></div></span><div>No, you don’t join arrays with objects (maps). You join the table representation of an array with the table representation of a map. And what you get back is a table, which of course you can query.</div><span><br></span></div></div></blockquote><div><br></div><div>Isn't there an impedance mismatch that has been hand-waved away somewhere in there.</div><div> </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"><div><span><blockquote type="cite"><div><div dir="ltr">Why not, or if so what type of thing will I get back and what will happen when if I try to query it (I will be allowed to query it won't I).<div><br></div><div>If I ask to order by a field and there is no schema to tell me it's type what is SQL going to do.</div></div></div></blockquote><div><br></div></span>JSON types are based on the syntax of the instance, not on any schema. If it looks like a number then it is a number. 4=4.0 is true, “4”=“4.0” is false.<span><br><blockquote type="cite"><div><div dir="ltr"><div><br></div></div></div></blockquote></span></div></div></blockquote><div>So I'm SOL if it's a date then. </div><div> </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"><div><span><blockquote type="cite"><div><div dir="ltr"><div></div><div>Talking of ordering how do I get the 5th array item or the 5th object when SQL only deals in unordered sets.</div></div></div></blockquote><div><br></div></span>SQL doesn’t deal only in unordered sets. It deals in tables. It has an “order by” operator. You’re probably thinking of the relational model, which is not the same as SQL.<span><br><blockquote type="cite"><div><div dir="ltr"><div><br></div></div></div></blockquote></span></div></div></blockquote><div>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><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span><blockquote type="cite"><div><div dir="ltr"><div></div><div>What would be the result of union of two objects and how can I determine whether such a union should be allowed at all when there is no schema?</div></div></div></blockquote><div><br></div></span>Again, it’s the union of two tables which are the representations of objects/maps, and the details depend on how you do the mapping.</div><span><div><br></div></span></div></blockquote><div><br></div><div>I'm not doing the mapping. You're the one who saying it can be done. </div><div><br></div><div>How do you map a potentially infinitely recursive data structure into a flat 2 dimensional table.</div><div><br></div><div>How would you  predict a priori what your table and column names would be and how many of them. Say  you had two semantically different (because they are at different levels of the hierarchy) but identically named tags what schema is that going to generate for your tables. </div><div><br></div><div>If you don't can't predict the schema your semi-structured is going to generate then  how could you write your query. Generate the tables first and then write it when you've seen what they've produced???</div></div></div></div>