Live data from Hacker News

PostgreSQL-Prolog: A Prolog library to connect to PostgreSQL databases

github.com

1–10 of 23 posts

Re: PostgreSQL-Prolog: A Prolog library to connect to PostgreSQL databases

#2
The Datalog query language is a subset of Prolog. I wonder how hard it would be to translate Datalog into SQL and query PostgreSQL with that. XTDB (aka Crux), which uses Datalog, supports some limited SQL querying. How limited would it be to go in the other direction?

Re: PostgreSQL-Prolog: A Prolog library to connect to PostgreSQL databases

#4
post #2

The Datalog query language is a subset of Prolog. I wonder how hard it would be to translate Datalog into SQL and query PostgreSQL with that. XTDB (aka Crux), which uses Datalog, supports some limited SQL querying. How limited would it be to go in the other direction?

If you’re ok with typecasting then it’s relatively straight forward. I think postgres has some convenient utility around that.

Re: PostgreSQL-Prolog: A Prolog library to connect to PostgreSQL databases

#5
post #3

This is extremely cool and I will be testing it out. I’m building large systems for handling biological data, and have wanted to use prolog for that use, but couldn’t fit all of my data in RAM. This could help me a bunch.

Importantly for this use case, Scryer Prolog represents lists of characters very compactly internally, using a sequence of raw bytes! It is the first Prolog system to use this efficient representation. This helps considerably when processing huge amounts of data, for example when parsing large text corpora with Prolog's built-in grammar mechanism, definite clause grammars (DCGs).

Re: PostgreSQL-Prolog: A Prolog library to connect to PostgreSQL databases

#7
post #2

The Datalog query language is a subset of Prolog. I wonder how hard it would be to translate Datalog into SQL and query PostgreSQL with that. XTDB (aka Crux), which uses Datalog, supports some limited SQL querying. How limited would it be to go in the other direction?

With recursive common table expressions it is really straightforward. You just have to manually stratify your datalog program to find out the order for the CTE.

And then you just write down all the rules.

edit: As long as queries aren't recursive in a difficult manner, like co-recursive or have multiple recursive calls in the same rule.

Post reply on HN