Skip to content

Instantly share code, notes, and snippets.

@yawnston
Created March 8, 2023 21:31
Show Gist options
  • Save yawnston/ac4c2acfc657ccf698a868932b419973 to your computer and use it in GitHub Desktop.
Save yawnston/ac4c2acfc657ccf698a868932b419973 to your computer and use it in GitHub Desktop.
JSS query proposal
# Notation -> is used as a simplification in place of a single morphism, for example 1 or -1. This is for simplification since I don't know the exact schema.
# Similarly ->> means a traversal like 1/2 or 1/-2 or similar, basically just a compound morphism traversal.
SELECT {
?result -> ?address ;
# Cypher-like aggregation - set of neighboring variables is the aggregation set (in this case streetName adn city)
-> COUNT(?sameAddressOrder) AS ?orderCount .
?address -> ?streetNumber ;
-> ?city .
} WHERE {
?order -> ?number ;
-> ?streetName ;
-> ?city ;
->> ?price .
# Cypher-like aggregation - set of neighboring variables is the aggregation set (in this case it's the order for all of its items)
FILTER(SUM(?price) > 500)
# Unification of variables - streetName will be the same value everywhere, no need to filter on equality
?customer -> ?order ;
-> ?streetName ;
-> ?city .
# All orders at the given address, not just the ones over 500 CZK
?sameAddressOrder -> ?streetName ;
-> ?city .
}
ORDER BY ?orderCount DESC
LIMIT 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment