proj-plbook-plChQueryLangs

Table of Contents for Programming Languages: a survey

Chapter : Query languages and graph languages

SQL

Example:

" Here’s an example. Let’s say we need data to create a “California revenue Q3” report.

You can create this report by writing one line of SQL that magically:

Fetches users from the California table Sorts the data Totals the data Orders the data so you can show one column that says “California revenue Q3 2017”

This is what the one line of SQL would like look:

SELECT SUM(Value_USD) AS California_Revenue_Q3 FROM Transactions WHERE Location = 'California' AND DATEPART(q, Date) = 3 AND YEAR(Date) = 2017;

And if we wanted to break it down by location the SQL would be as follows:

SELECT Location, SUM(Value_USD) AS Revenue_Q3 FROM Transactions WHERE DATEPART(q, Date) = 3 AND YEAR(Date) = 2017 GROUP BY Location ORDER BY Location;

And if we wanted the top five areas by revenue:

SELECT TOP 5 Location, SUM(Value_USD) AS Revenue_Q3 FROM Transactions WHERE DATEPART(q, Date) = 3 AND YEAR(Date) = 2017 GROUP BY Location ORDER BY SUM(Value_USD) DESC; " -- [1]

SQL Tutorials

SQL Courses

SQL opinions

Linq

htsql

MDX

xpath

I think 1.0 is not Turing-complete, but 2.0 is? http://homepages.inf.ed.ac.uk/wenfei/cs2/lecture/ln3.pdf

XQuery

Extends XPath. Turing-complete.

Opinions:

XQBE

Subset of XQuery. Not Turing-complete.

http://wwwconference.org/www2003/cdrom/papers/poster/p291/p291-braga.html

gremlin

Turing complete.

GP

https://www.cs.york.ac.uk/plasma/wiki/index.php?title=GP_(Graph_Programs)

For solving complex graph problems. Has a complete formal semantics.

SPARQL

GraphQL

https://graphql.org/ http://facebook.github.io/graphql/

discussion:

MQL

http://wiki.freebase.com/wiki/MQL

ANDL

http://www.andl.org/ http://www.andl.org/welcome-to-andl/

QUEL

https://en.wikipedia.org/wiki/QUEL_query_languages

discussion:

EdgeDB / edgeql

https://edgedb.com/blog/we-can-do-better-than-sql/ https://www.edgedb.com/showcase/edgeql https://www.edgedb.com/docs/tutorial/queries https://www.edgedb.com/blog/edgedb-1-0

Opinions:

JuliaDB

https://juliadata.github.io/JuliaDB.jl/latest/

Emacs Org-mode matching language

For querying org-mode headlines.

The query is a disjunction of conjunctions. Each conjunction is a conjunction of a number of conditions, and each condition can be negated. The conditions may be the binary presence/absence of tags, or may be whether or not a given regular expression matches various parts of the headline (for example, headlines may have todo statuses and priorities, which may be matched against regular expressions.

See:

XMLPL

http://xmlpl.org

dplyr

Opinions:

Preql

https://github.com/erezsh/Preql

Retrospectives:

prql

https://prql-lang.org/ https://github.com/prql/prql https://github.com/max-sixty/prql

Example:

from employees filter country = "USA" # Each line transforms the previous result. let gross_salary = salary + payroll_tax # This _adds_ a column / variable. let gross_cost = gross_salary + benefits_cost # Variables can use other variables. filter gross_cost > 0 aggregate by:[title, country] [ # `by` are the columns to group by. average salary, # These are the calcs to run on the groups. sum salary, average gross_salary, sum gross_salary, average gross_cost, sum gross_cost, count, ] sort sum_gross_cost # Uses the auto-generated column name. filter count > 200 take 20

Discussion:

PromQL

Logica

https://logica.dev/ https://opensource.googleblog.com/2021/04/logica-organizing-your-data-queries.html https://colab.sandbox.google.com/github/EvgSkv/logica/blob/main/tutorial/Logica_tutorial.ipynb https://github.com/EvgSkv/logica

Alf

https://www.try-alf.org/about/ https://www.try-alf.org/doc/ https://www.try-alf.org/cheatsheet/ https://www.try-alf.org/blog/2013-10-21-relations-as-first-class-citizen https://www.try-alf.org/

Opinions:

See also Bmg

Bmg

https://github.com/enspirit/bmg "Bmg, a relational algebra (Alf's successor)!"

D

https://en.wikipedia.org/wiki/D_(data_language_specification) https://en.wikipedia.org/wiki/D_(data_language_specification)#Tutorial_D

Alf

https://github.com/alf-tool/alf https://www.try-alf.org/

i think it's related to The Third Manifesto / Tutorial D

Cypher

Neo4j's graph query language

Opinions:

Datalog

http://www.learndatalogtoday.org/ (Datomic dialect of Datalog)

Used by Datascript.

Differential Datalog variant

ColumnSQL

https://prosto.readthedocs.io/en/latest/text/column-sql.html

CodeQL/QL

https://codeql.github.com/docs/writing-codeql-queries/introduction-to-ql/ https://codeql.github.com/docs/ql-language-reference/ https://lgtm.com/

Used by Semmle.

jOOQ

https://www.jooq.org/

Ecto.Query

https://hexdocs.pm/ecto/Ecto.Query.html

imp

https://github.com/jamii/imp

See also the imp subsection in https://scattered-thoughts.net/

duckDB

https://duckdb.org/2022/05/04/friendlier-sql.html

discussion: https://news.ycombinator.com/item?id=31355050

Relational pipes

https://relational-pipes.globalcode.info/v_0/examples.xhtml

note: everything else on this website, and the project source code, seems to be pretty hard to understand due to (a) its incomplete nature, and (b) lack of overview documentation (there is plenty of documentation covering why it's needed and the design principals, but not so much documentation on the concrete data model used). However, the examples on this page are good; so if you just want an overview, i recommend reading the examples linked from this page, but not spending time poking around on the rest of this website, or the source code.

Malloy

Dataframe libraries

Iverson array language databases

Zed

https://zed.brimdata.io/docs/language/overview/ https://zed.brimdata.io/docs/tutorials/zq/ https://www.brimdata.io/blog/introducing-zq/

Relational Calculus

Examples:

See also:

Notes: ""Third, we remind you that types are not limited to simple things like integers. Indeed, we saw in Chapter 1 that values and variables can be arbitrarily complex—and that is so precisely because the types of those values and variables can be arbitrarily complex. Thus, to paraphrase a remark from that chapter, a type might consist of geometric points, or polygons, or X rays, or XML documents, or fingerprints, or arrays, or stacks, or lists, or relations (and on and on)." (page 56, Databases, types, and the relational model: the third manifesto by C.J. Date and Hugh Darwen

Lists of query langs

lists some company-specific query languages: SPL (Mixpanel), JQL (Rollbar), RQL (New Relic), NRQL (New Relic), AWQL (Adwords)