compiling [Head|Tail] to SQL

Viewed 214

Prolog constructs are list oriented, since lists allow to merge the tuple-at-once Prolog model to the all-solutions relational model (SQL, let's say).

I was thinking about to compile list processing Prolog code to SQL.

I think Draxler's compiler pl2sql does not address the problem (appropriately, the term list is never used...).

I was thinking about a column to pair translation,

append(A,B,C) ~~>
    table(append, A_key,A_val, B_key,B_val, C_key,C_val)

where _key would be row IDs, and express relations with different self joins, selected depending on instancing status of head' Variables.

The alternative design could be

append(A,B,C) ~~>
    table(append_A, key, val), table(append_B, key, val), table(append_C, key, val)

with joins, instead of self joins as above.

Does anyone know about precedent work ?

What about about feasibility ? In particular, could stored procedure be avoided ?

edit I've found FunSQL document, should be relevant... going to read.

1 Answers
Related