Users of typical relational algebra engines have come to expect sorting and limiting of query results despite the fact that relations do not support ordering. To that end, Project:M36 supports converting relations to "data frames" to support sorting on attributes and limiting the maximum tuple count in the result set.
The equivalent feature in SQL is invoked by the ORDER BY, LIMIT, and OFFSET clauses.
From within the tutd console, converting a relation to be sorted as a data frame is invoked using the :showdataframe command.
:showdataframe <relational expression> orderby {<attribute {ascending,descending}>} {offset <num>} {limit <num>}
The default sort order is ascending.
TutorialD (master/main): :showdataframe s orderby {status}
ββββ¬ββββββββββββ¬ββββββββββ¬βββββββββββββ¬βββββββββββββββββ
βDFβcity::Textββs#::Textββsname::Textββstatus::Integerβ¬β
ββββΌββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββ€
β1 β"Paris" β"S2" β"Jones" β10 β
β2 β"London" β"S1" β"Smith" β20 β
β3 β"London" β"S4" β"Clark" β20 β
β4 β"Athens" β"S5" β"Adams" β30 β
β5 β"Paris" β"S3" β"Blake" β30 β
ββββ΄ββββββββββββ΄ββββββββββ΄βββββββββββββ΄βββββββββββββββββ
TutorialD (master/main): :showdataframe s{status} orderby {status}
ββββ¬βββββββββββββββββ
βDFβstatus::Integerβ¬β
ββββΌβββββββββββββββββ€
β1 β10 β
β2 β20 β
β3 β30 β
ββββ΄βββββββββββββββββ
TutorialD (master/main): :showdataframe s{status} orderby {status descending} limit 1
ββββ¬βββββββββββββββββ
βDFβstatus::Integerβ¬β
ββββΌβββββββββββββββββ€
β1 β30 β
ββββ΄βββββββββββββββββ
TutorialD (master/main): :showdataframe s{status} orderby {status descending} offset 1 limit 3
ββββ¬βββββββββββββββββ
βDFβstatus::Integerβ¬β
ββββΌβββββββββββββββββ€
β1 β20 β
β2 β10 β
ββββ΄βββββββββββββββββ
The arrow in the attributes indicates the sort order while the DF column indicates the row number based on the sort order. Column ordering can also be arbitrary.