Relational Expressions

     <relation exp>
         ::=   <with exp> | <nonwith exp>

     <with exp>
         ::=   WITH ( <name intro commalist> ) : <relation exp>

     <name intro>
         ::=   <relvar name> := <relation exp>

     <nonwith exp>
         ::=   <image exp> | <relation op> | ( <relation op> )
     <image exp>
         ::=   !!<nonwith exp> | ( <image exp> )

     <relation op>
         ::=   <relation selector> | <monadic op> | <dyadic op> | <n-adic op>

     <relation selector>
         ::=   RELATION [ <heading> ] { <tuple exp commalist> }
             | TABLE_DUM | TABLE_DEE

     <heading>
         ::=   { <attribute commalist> }

     <attribute>
         ::=   <attribute name> <type name>

     <monadic op>
         ::=   <relvar name> | <rename> | <where> | <project>
             | <extend> | <group> | <ungroup> | <tclose>

     <rename>
         ::=   <relation exp> RENAME { <renaming commalist> }

     <renaming>
         ::=   <attribute name> AS <attribute name>

     <where>
         ::=   <relation exp> WHERE <bool exp>

     <project>
         ::=   <relation exp> { [ ALL BUT ] <attribute name commalist> }

     <extend>
         ::=   EXTEND <relation exp> : { <attribute assign commalist> }

     <attribute assign>
         ::=   <attribute name> := <exp>

Note: An alternative form of <attribute assign>, syntactically identical to a <relation assign> except that the pertinent <attribute name> appears in place of the target <relvar name> in that <relation assign>, is also supported if the attribute in question is relation valued.

     <group>
         ::=   <relation exp> GROUP
                        ( { [ ALL BUT ] <attribute name commalist> }
                                                     AS <attribute name> )

     <ungroup>
         ::=    <relation exp> UNGROUP ( <attribute name> )

     <tclose>
         ::=    TCLOSE ( <relation exp> )

     <dyadic op> ...

Get SQL and Relational Theory, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.