3 ms·
This is actually not true. Prolog is Turing complete, SQL is not. WITH RECURSIVE is limited to cases where you could basically use a simple foreach loop. The po
by zenhack 7y ago
This is actually not true. Prolog is Turing complete, SQL is not. WITH RECURSIVE is limited to cases where you could basically use a simple foreach loop. The postgres manual has this to say:
> Note: Strictly speaking, this process is iteration not recursion, but RECURSIVE is the terminology chosen by the SQL standards committee.
That said, the feature was to some degree inspired by datalog.
EDIT: I should probably clarify, many dbmses probably have extensions that do make SQL turing complete, and the current standard is if you count stored procedures I guess. But CTEs themselves are more limited than what Prolog does.
- samatman 7y ago>Prolog is Turing complete, SQL is not. This is actually not true. Behold, a cyclic tag system in SQL:2003-conformant SQL: http://wiki.postgresql.org/wiki/Cyclic_Tag_System http://wiki.postgresql.org/wiki/Cyclic_Tag_System Here's a blog diving into more detail: http://blog.coelho.net/database/2013/08/17/turing-sql-1.html http://blog.coelho.net/database/2013/08/17/turing-sql-1.html Although this is less strictly conforming. The original thread was in the context of SQLite, which is trivially of equivalent computational power. However, again: you should probably use Prolog.
- zenhack 7y agoI stand corrected. I wish there was some nice off the shelf embed able FOSS DB like SQLite, but with datalog as a query language.