Transcription from SQL to FOL (First Order Logic)

Click For Summary

Discussion Overview

The discussion revolves around the transcription of SQL queries into First Order Logic (FOL), particularly focusing on how complex queries, such as joins and unions, are represented in FOL. Participants explore the mapping of SQL constructs to logical expressions and the implications for model representation.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant questions the transcription map for complex SQL queries, specifically regarding joins and whether product models or union models are used.
  • Another participant proposes a representation for the Inner Join of two tables in FOL, suggesting a specific wff structure with free variables based on the tables' predicates.
  • A follow-up inquiry seeks clarification on how the model of a union would be defined, proposing a wff that incorporates the union of the two models represented by the respective predicates.

Areas of Agreement / Disagreement

Participants express differing views on the appropriate representation of joins and unions in FOL, indicating that multiple competing models remain under discussion.

Contextual Notes

The discussion does not resolve the assumptions regarding the definitions of models or the specific conditions under which the proposed representations hold true.

WWGD
Science Advisor
Homework Helper
Messages
7,806
Reaction score
13,120
Hi All,
When a query is made in SQL , it is transcribed into FOL in the back end , and, if the transcription is a wff , the models, if any, are returned as the answer to the query. I have an idea of how the transcription works for basic statements, but, does anyone know the actual " transcription map" for more complicated queries, such as, e.g., joins? Do we use product models in this case, or do we union the models to form new ones?
 
Physics news on Phys.org
I'll have a go at this, since nobody else has.

If a table in the database is represented by an atomic wff, and we have tables ##p,q## represented by the a ##m##-ary predicate ##P## and a ##n##-ary predicate ##Q## respectively, then I think the Inner Join of the two tables on the first ##r## arguments to both tables, in the same order, will be represented by the following wff with ##m+n-r## free variables:
$$P(x_1,...,x_m)\wedge Q(x_1,..x_r,x_{m+1},...,x_{m+n-r})$$
 
  • Like
Likes   Reactions: WWGD
andrewkirk said:
I'll have a go at this, since nobody else has.

If a table in the database is represented by an atomic wff, and we have tables ##p,q## represented by the a ##m##-ary predicate ##P## and a ##n##-ary predicate ##Q## respectively, then I think the Inner Join of the two tables on the first ##r## arguments to both tables, in the same order, will be represented by the following wff with ##m+n-r## free variables:
$$P(x_1,...,x_m)\wedge Q(x_1,..x_r,x_{m+1},...,x_{m+n-r})$$
Thanks, Andrew, how would the model of the union then be defined, as just a set union of the two models ( the models of the two wffs)?
 
WWGD said:
Thanks, Andrew, how would the model of the union then be defined, as just a set union of the two models ( the models of the two wffs)?
I think I'd try the following for
Code:
 select x1,x2,...,xr from p UNION select x1,x2,...,xr from q
$$\exists x_{r+1},x_{r+2},...,x_{m+n-r}:\ P(x_1,...,x_m)\vee Q(x_1,...,x_r,x_{m+1},...,x_{m+n-r})$$
This wff has ##r## free variables, corresponding to the ##r## columns in the tables ##p## and ##q## that match.
 

Similar threads

  • · Replies 26 ·
Replies
26
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
605
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 0 ·
Replies
0
Views
3K