on master help sign in
add documentation for new TutorialD syntax for union and intersection attribute expressions
commit66f4d993babe77841b7c38b9dac65eb853f97121 authorAgentM <agentm@themactionfaction.com> dateSun 22 Nov 2020, 14:25 (6 years ago) parent028a0e4
1 file changed+37−1
docs/tutd_tutorial.markdown+37−1
docs/tutd_tutorial.markdown+37−1
@@ -197,7 +197,7 @@ TutorialD (master/main): :showexpr s{all but city}
197197└────────┴───────────┴───────────────┘
198198```
199199
200−Projection attributes can also be derived from a relational expression using `all from`:
200+Projection attributes can be derived from a relational expression using `all from`:
201201
202202```
203203TutorialD (master/main): :showexpr (s join sp){all from s}
@@ -213,6 +213,42 @@ TutorialD (master/main): :showexpr (s join sp){all from s}
213213
214214Above, we join `s` and `sp` but project the result back onto the attributes of `s`.
215215
216+Projection attributes can be unioned from multiple sources using `union of`:
217+
218+```
219+TutorialD (master/main): :showexpr (s join sp){union of {all from s} {all but p#}}
220+┌──────────┬────────────┬────────┬───────────┬───────────────┐
221+│city::Text│qty::Integer│s#::Text│sname::Text│status::Integer│
222+├──────────┼────────────┼────────┼───────────┼───────────────┤
223+│"Paris" │400 │"S2" │"Jones" │10 │
224+│"London" │400 │"S1" │"Smith" │20 │
225+│"Paris" │200 │"S3" │"Blake" │30 │
226+│"London" │200 │"S4" │"Clark" │20 │
227+│"London" │200 │"S1" │"Smith" │20 │
228+│"Paris" │300 │"S2" │"Jones" │10 │
229+│"London" │100 │"S1" │"Smith" │20 │
230+│"London" │300 │"S4" │"Clark" │20 │
231+│"London" │300 │"S1" │"Smith" │20 │
232+│"London" │400 │"S4" │"Clark" │20 │
233+└──────────┴────────────┴────────┴───────────┴───────────────┘
234+```
235+
236+Here, after joining `s` and `p`, the union of all attributes from `s` and all attributes from `p` except for `p#` are returned.all
237+
238+Finally, projection attributes can be intersected using `intersection of`:
239+
240+```
241+TutorialD (master/main): :showexpr (s join sp){intersection of {all from s} {all from p}}
242+┌──────────┐
243+│city::Text│
244+├──────────┤
245+│"London" │
246+│"Paris" │
247+└──────────┘
248+```
249+
250+Here, after joining `s` and `p`, we project on the intersection of attributes from `s` and `p` which happens to be `city`.
251+
216252#### Restriction
217253
218254Restriction is applied using a "where" clause, much like in SQL.