Aliases are Snooze’s mechanism for letting you to refer to individual instances of an entity or expression within a query.
You can introduce aliases for entities, attributes or expressions using the following forms (see below for examples):
|( id expr)|
Introduces an alias for expr using the same scoping rules as .
|( ([id expr] ) body-expr )|
Like but uses the same scoping rules as .
It is sometimes necessary to refer to more than one instance of an entity within a query. Snooze lets you do this by defining aliases for entities. For example:
|( father person)|
|; Luke's father:|
|( (select #:what father|
|#:from ( person|
|( person.father-id father.id))|
|#:where ( person.name "Luke"))))|
It is sometimes useful to assign an alias to an attribute or expression.
For example, if you are #:ordering on an expression, SQL 97 requires you to add the same expression to your #:what clause. The only way to do this is to alias the expression:
|; All people and BMIs, ordered by BMI:|
|( ([bmi ( person.weight person.height)])|
|( (select #:what (person bmi)|
|#:order ((asc bmi))))))|