Cheat Sheet¶
Relational Operators¶
Selection |
|
Projection |
|
Theta-Join |
|
Natural join |
|
Cross product |
|
Set union, difference, and intersection |
|
Rename |
|
Aggregation (not in standard relational algebra) |
|
Writing Relational Algebra Queries¶
End every query with a semicolon (
;
).The simplest query is one that returns a database relation, i.e.: relation_name
;
Build a complex query by nesting: you can feed a subquery as an input relation to another relational operator (using parentheses to enclose the subquery as necessary to avoid ambiguity) , e.g.:
\select_{
condition} (\project_{
attr_list}
input_relation_1) \join
input_relation_2;
Commands¶
|
Exit from RA |
|
List database relations and user-defined views |
|
Clear all user view definitions |
|
Clear definition for view v as well as any views that depend on v (directly or indirectly) |
|
Save all user view definitions to file.ra |
|
Save to file.ra the definition of view v as well as definitions of any views that v depends on (directly or indirectly) |
|
Execute RA statements from ra_file |
|
Execute the SQL statement (a single one, not terminated by
|