In my opinion any analytical query is easier to read in logic language than in SQL. But it's most obvious for recrusive querries. E.g. distance in graph defined by predicate (aka table) G written in Logica looke like:
D(a, b) Min= 1 :- G(a, b); # Connected by an edge => distance 1.
D(a, c) Min= D(a, b) + D(b, c); # Triangle inequality.
It will be much harder to read with SQL CTE.
It can also computed over weighted graphs, which is impossible or extremely hard with SQL.
In practice you rarely need recursive querries, so gap between Logica and SQL isn't as large as it is here, but Logica is easier to read (in my opinion) for similar reasons.
I think of Prolog as a general purpose logic programming language and Datalog to be logic programming more focused on data analysis. Data analysis is a very large area, so boundary might get blurry at times.
If your data is in a relational database consider Logica - a Datalog family language that compiles to SQL and runs naturally on SQLite, Postgres, DuckDB and Google BigQuery.
Easy to install, easy to play with in CoLab or any other Jupyter notebook.
Works for data analysis (aggregation, filtering etc) that is commonly associated with SQL, as well as recursive logical querries commonly associalted with Logic programming per-se.
Here is what it looks like for a data-analysis-ish query of finding popular baby names over time:
# Count babies per year.
NameCountByYear(name:, year:) += number :-
BabyNames(name:, year:, number:);
# For each year pick the most popular.
TopNameByYear(year) ArgMax= name -> NameCountByYear(name:, year:);
# Accumulate most popular name into a table, dropping the year.
PopularName(name: TopNameByYear());
The classic grand-parent rule looks as usual:
Grandparent(a, c) :- Parent(a, b), Parent(b, c);
Here is a recursive program for finidng distances in a directed graph:
Looks like Mangle differs from Prolog when it needs to express aggregation.
I am curious what prolog dialect/library you think has good(or best?) aggregation syntax?
In practice you rarely need recursive querries, so gap between Logica and SQL isn't as large as it is here, but Logica is easier to read (in my opinion) for similar reasons.