Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
<code>σ firstname = 'Bob' or firstname = 'Alice' ( Customer )</code>
<div>
<code>σ (id > 10 and id {'<'} 100) or id = 42 ( Customer )</code>
</div>
<div>
Selecting all customers with a firstname that has an even length.
<code>σ mod(length(firstname),2) = 0 ( Customer )</code>
</div>
<div>
</div>
<div>
<h4 id="relalg-operations-renamerelation">rename relation</h4>
<table>
<tbody>
<tr>
<th>symbol</th>
<td>ρ</td>
</tr>
<tr>
<th>alternative syntax</th></tr></tbody></table></div>
<h4 id="relalg-relalgexpr">relational algebra expression</h4>
<div>
<p>A valid relational algebra expression is built by connecting <i>relation-name</i> or <i>inline-relation</i>
as atoms with the defined unary and binary operators.</p>
So a relational algebra expression is recursively defined as follows:
<div>
</div></div>
Sequence(
NonTerminal('expression', '#sql-valueexpr'),
Sequence('AS', NonTerminal('output_name'))
)
),
','
),
),
Terminal('FROM', '#sql-from'),
OneOrMore(
Choice(
0,
Sequence(
NonTerminal('table_name'),
Optional(Sequence('AS', NonTerminal('alias')))
),
Sequence(
'(', NonTerminal('select'), ')',
Sequence('AS', NonTerminal('alias'))
)
),
',',
),
),
OneOrMore(
Choice(
0,
Skip(),
Sequence(
Choice(
alternative syntax
anti semi join<br>anti join
<div>no argument
<br>
<div>
</div>
</div>
<h3 id="relalg-operator-precedence">Operator precedence</h3>
<p>The operator precedence allows to obmit most of braces.
<br>The used precedence is shown in the table below.
<br>All operators are left associative.</p>
return new rr.ZeroOrMore(renderTok(tok.ebnf));
break;
case ":?":
return new rr.Optional(renderTok(tok.ebnf));
break;
}
} else if (tok.literal) {
return new rr.Terminal(JSON.stringify(tok.literal));
} else if (tok.mixin) {
return new rr.Comment("Pas implementé.");
} else if (tok.macrocall) {
return new rr.Comment("Pas implementé.");
} else if (tok.tokens) {
return new rr.Sequence(tok.tokens.map(renderTok));
} else if (typeof(tok) === 'string') {
return new rr.NonTerminal(tok);
} else if (tok.constructor === RegExp) {
return new rr.Terminal(tok.toString());
} else if (tok.token) {
return new rr.Terminal(tok.token);
} else {
return new rr.Comment("[Unimplemented]");
}
}
Sequence(
Optional(
Sequence(
Choice(
0,
'UNION',
'INTERSECT',
'EXCEPT'
),
Choice(
0,
Skip(),
'DISTINCT',
'ALL'
),
NonTerminal('select')
),
'skip',
),
Optional(
Sequence(
Terminal('ORDER BY', '#sql-orderby'),
OneOrMore(
Sequence(
NonTerminal('expression', '#sql-valueexpr'),
Choice(
0,
'ASC',
'DESC'
)
),
','
as atoms with the defined unary and binary operators.<p></p>
So a relational algebra expression is recursively defined as follows:
<div>
</div>
NonTerminal('selection', '#relalg-operations-selection'),
NonTerminal('rename relation', '#relalg-operations-renamerelation'),
NonTerminal('rename column', '#relalg-operations-renamecolumn'),
NonTerminal('order by', '#relalg-operations-orderby'),
NonTerminal('group by', '#relalg-operations-groupby')
),
NonTerminal('RA-expression', '#relalg-relalgexpr')
)
),
Choice(
1,
Skip(),
Sequence(
Choice(
0,
NonTerminal('intersection', '#relalg-operations-intersection'),
NonTerminal('union', '#relalg-operations-union'),
NonTerminal('division', '#relalg-operations-division'),
NonTerminal('subtraction', '#relalg-operations-subtraction'),
NonTerminal('cross product', '#relalg-operations-crossjoin'),
NonTerminal('θ-join', '#relalg-operations-innerjoin'),
NonTerminal('natural join', '#relalg-operations-naturaljoin'),
NonTerminal('left outer join', '#relalg-operations-leftjoin'),
NonTerminal('right outer join', '#relalg-operations-rightjoin'),
NonTerminal('full outer join', '#relalg-operations-fulljoin'),
NonTerminal('left semi join', '#relalg-operations-leftsemijoin'),
NonTerminal('right semi join', '#relalg-operations-rightsemijoin'),
NonTerminal('anti semi join', '#relalg-operations-antijoin')
),
NonTerminal('RA-expression', '#relalg-relalgexpr')
)
)
where countOrders could be the result of a previous aggregation.
<code>pi firstname, lastname
sigma rownum() {'<'}= 5
tau countOrders desc
Customer
</code>
<div>
</div>
<div>
<h4 id="relalg-operations-selection">selection</h4>
<table>
<tbody>
<tr>
<th>symbol</th>
<td>σ</td>
</tr>
<tr>
<th>alternative syntax</th>
<td>pi</td>
</tr></tbody></table></div>