Re: type checking SQL expressions

George Neuner <gneuner2@comcast.net>
24 Mar 2005 21:14:22 -0500

          From comp.compilers

Related articles
type checking SQL expressions jean.morissette666@videotron.ca (Jean Morissette) (2005-03-20)
Re: type checking SQL expressions gneuner2@comcast.net (George Neuner) (2005-03-24)
Re: type checking SQL expressions Brian.Inglis@SystematicSW.ab.ca (2005-03-25)
Re: type checking SQL expressions gene@abhost.us (Gene Wirchenko) (2005-03-27)
Re: type checking SQL expressions Brian.Inglis@SystematicSW.ab.ca (Brian Inglis) (2005-03-31)
Re: type checking SQL expressions jean.morissette666@videotron.ca (Jean Morissette) (2005-04-11)
Re: type checking SQL expressions gneuner2@comcast.net (George Neuner) (2005-04-16)
| List of all articles for this month |

From: George Neuner <gneuner2@comcast.net>
Newsgroups: comp.compilers
Date: 24 Mar 2005 21:14:22 -0500
Organization: Compilers Central
References: 05-03-076
Keywords: SQL, types
Posted-Date: 24 Mar 2005 21:14:22 EST

On 20 Mar 2005 11:12:41 -0500, Jean Morissette
<jean.morissette666@videotron.ca> wrote:


>I want to build a simple SQL compiler and I would like to know if a
>formal specification of the type system used in SQL has been written
>somewhere?


If it has, I've never seen it. The types in a SQL query are ad hoc
and are completely defined by the constants in the query and the DDL
structure of the tables involved.




>It seems to me that the type system of SQL is incoherent.
>I let an exemple below that explain my affirmation.
>
>"SELECT column1 FROM table2 WHERE column3 > 9"
>the type of column3 is integer instead of tuple(integer)


It's not the type system - it's the syntax.


You're misunderstanding the query. The WHERE clause specifies that
any tuples to be included in the result set must satify a range
restriction on the value of column3.


Try reading it in relational pidgin:


project column1 from
table2 restricted by value(column3) > 9


You need to concern yourself with understanding the syntax of SQL and
what the query is really asking. You also need to understand the
various entities defined by the relational model and their
relationships to each other. I suggest, if you haven't already, that
you read up on the relational model, relational algebra and on the SQL
implementation of them.


George



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.