I can see relation models can be represented as graphs (e.g., table foreign keys to another table are "edges"; fields in the table that are not primary keys are "properties")
However, I am not quite confident in the claim that arbitrary graphs being mappable as relational models. I suspect there are certain graphs that can be difficult to express as relational models.
So question for you: Would you say all Trustfall expressions can be translated to SQL? Or, there are cases where there's no such translation possible?
I'm not sure about arbitrary graphs, because all kinds of weird and wonderful math exists out there :)
But from 7 years of working on graph databases, and even participating in some graph query language standardization work, I know two things:
- Anything a graph database can represent and store, a relational db can also represent and store.
- Trustfall's representational power is broader than what either of those would reasonably represent.
I say reasonably because, for example, with sufficient contortions you could make SQL to give you function-like edges like you'd expect in an API. Table-valued functions are awesome! But if every one of your joins was via a TVF ... you'd have a number of problems.
Examples: in Trustfall, you can write a query that asks for the prime factors of all numbers in a given range, without having precomputed or stored any of that data -- it can be computed and loaded "on-demand". You can also have an edge like `divisors_that_are_multiples(of: Int!)` that requires an integer to be provided before being able to be resolved. Both of these are possible to represent in modern SQL, if you try hard enough. But should you? Absolutely not, or you won't be happy with the outcomes.
To make true datasource-agnostic querying, you can't start with a "preferred datasource" that everything else must translate to. Either all data sources are equal, or else there's a massive incentive to use the preferred one at the expense of all else -- so there are massive incentives to optimize predominantly for the preferred source, and we're right back at square one.
In https://www.hytradboi.com/2022/how-to-query-almost-everythin... @ 4:15, you mentioned data modeled as graphs are equivalent to relational models.
I can see relation models can be represented as graphs (e.g., table foreign keys to another table are "edges"; fields in the table that are not primary keys are "properties")
However, I am not quite confident in the claim that arbitrary graphs being mappable as relational models. I suspect there are certain graphs that can be difficult to express as relational models.
So question for you: Would you say all Trustfall expressions can be translated to SQL? Or, there are cases where there's no such translation possible?