Fork me on GitHub
#xtdb
<
2022-10-21
>
tatut05:10:16

I tried the core2 examples yesterday, and the joins are done with like in SQL traditionally (ie JOIN othertable ON thistable.id=othertable.id style)… is there a “ref” type that uniquely can refer to a single document/object/entity like :xt/id? How would a later datalog query engine for core2 work without that? am I missing something.

refset09:10:04

You mean like JOIN othertable ON thistable.id=othertable.id WHERE thistable.id = 'foo'?

refset09:10:36

> How would a later datalog query engine for core2 work without that? A Datalog->SQL compiler (like https://github.com/EvgSkv/logica) would probably work like that. If you're curious about how our existing Datalog-on-Core2 spike maps to the internal representation (IR) then you could try playing with this ns: https://github.com/xtdb/core2/blob/master/test/core2/datalog/datalog_test.clj

tatut09:10:11

I mean just like you can do nested pulls SELECT post.title, post.author.firstname, post.author.lastname FROM post where you wouldn’t need to explicitly join an author table, as the “author” attribute of the post would be a link to a author doc

👍 1
tatut09:10:14

and the author would be a link, not nested data in the post “table”

tatut09:10:09

but yeah, I’ll check out the datalog->sql compiler, thanks for the link

👌 1
tatut09:10:18

in xtdb1 and datalog I can just “join” any type of entity, as the attribute value is the :xt/id I don’t need to encode that “this id number refers to this table” in the query

refset10:10:55

Ah I see, well with Core2 you could go quite far with having all data in a single "universal" table if you really want, such that you don't need to reason in terms of tables at all and all joins can be self-joins. However short of doing that - and there would invariably be some performance/expressiveness downsides to that pattern - I expect you could use CTEs to paper over some of the more gnarly join constructions and simplify some queries. Further down the road we would like to implement https://www.iso.org/standard/79473.html?browse=tc (currently still only a "draft")

refset10:10:12

> I mean just like you can do nested pulls SELECT post.title, post.author.firstname, post.author.lastname FROM post where you wouldn’t need to explicitly join an author table, as the “author” attribute of the post would be a link to a author doc I wouldn't rule out for this specific example though that there may yet be an XT-specific SQL extension we create to make something a bit more convenient like this possible (similar to how we plan to pull in other schemaless SQL ideas from https://partiql.org/assets/PartiQL-Specification.pdf etc.) Broadly speaking though we hope to implement the standard well enough that more advanced tooling and other/existing ergonomic abstractions can be built atop. I'm 100% just playing here, imagining; SELECT post.title, post{author, author}.firstname, post{author, author}.lastname FROM post

🤞 1
tatut10:10:33

for me, part of the appeal of datalog is having just entities that can link to other entities, instead of thinking in tables

1