5 ms·
SQL
by User23 5y ago
SQL
- parafactual 5y agoWhat?
- blihp 5y agoSQL and Prolog have a large area of functional overlap as they are both based on predicate logic. However, SQL more naturally aligned with the database-centric worldview of many business systems and offered a more natural way (for business users) to ask business questions. So when SQL took off, it was adopted for many solutions where Prolog might have been used previously.
- YeGoblynQueenne 5y agoUgh, no. SQL is a special-purpose database language. I've tried to look at Prolog from a databases point of view and it makes no sense that way. Even datalog (a decidable subset of Prolog without functions and negation) doesn't make that much sense from a databases point of view and it was specifically designed as a database language from the start, far as I can tell. In practical terms, SQL is like one third of Prolog. Prolog programs are stored in a database as sets of Horn clauses that can be conditionally true (definite clauses or "rules"), unconditionally true (unit clauses or "facts") or unconditionally false (Horn goals, or "queries"). A Prolog program is executed by trying to refute a Horn goal by proving it false in the context of the program with an automated theorem prover and binding the variables in the goal in the process. Unit clauses correspond to database rows in SQL, so a SQL database is basically a set of "facts", seen from the Prolog point of view. But there are no "rules" and "queries" in the database - instead the program is written in an altogether different language that sits on top of the "facts" in the database. So from the point of view of Prolog, SQL is two languages only one of which bears some resemblance with Prolog. From the point of view of SQL also, Prolog is proabably quite alien - you can write recursive loops with your database rows O.o They're just two very different languages anyway you look at them.