Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 552 lines (436 sloc) 17.807 kb
344ecd2d »
2012-03-20 [Doc] Described basic features of the YZ.
1 # YZ
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
2
cbb0f04f »
2012-04-05 [Doc] Fixed table of contents.
3 * <a href="#simple_collection">Simple collection</a>
4 * <a href="#selection">Selection</a>
5 * <a href="#projection">Projection</a>
6 * <a href="#filtering">Filtering</a>
7 * <a href="#sorting">Sorting</a>
8 * <a href="#calling_function">Calling user function</a>
9 * <a href="#removing_dupls">Removing duplicates</a>
10 * <a href="#complex_model">More complex model</a>
11 * <a href="#joining">Joining</a>
79fe7b9f »
2012-04-10 [Doc] Minor changes.
12 * <a href="#joining_not_result">Joining without including to result</a>
cbb0f04f »
2012-04-05 [Doc] Fixed table of contents.
13 * <a href="#union">Union</a>
14 * <a href="#subquery">Subquery in right side of predicates</a>
15 * <a href="#table_typed_notyped">Table with typed and not typed symbols</a></li>
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
16
17 <a name="simple_collection"></a>
18 ## Simple collection
344ecd2d »
2012-03-20 [Doc] Described basic features of the YZ.
19 For demostration features of the YZ we will use some examples. First example is
5b5596e6 »
2012-04-06 [Doc] Fixed SYNTAX.md document.
20 collection with string values. Let's define this collection something like this:
6268cf23 »
2012-03-16 [Doc] Minor changes of docs.
21
5b5596e6 »
2012-04-06 [Doc] Fixed SYNTAX.md document.
22 ["Bob" "Alice" "" "Marry" "Kris" "David" "Alexander"]
703fa59c »
2012-03-15 [Doc] Inited description syntax.
23
5b5596e6 »
2012-04-06 [Doc] Fixed SYNTAX.md document.
24 In order to test and usage our examples you can use existing implementation of the YZ for
25 Clojure/Java object model. Follow to [this] (https://github.com/vdim/yz/blob/master/doc/TESTINGCOLLQ.md)
26 instruction for using queries for simple collection.
703fa59c »
2012-03-15 [Doc] Inited description syntax.
27
4a6f2c8e »
2012-03-20 [Doc] Fixed typos and errors into description of syntax.
28 We will hold the following notation: first will be query and second - result of query after "=>":
703fa59c »
2012-03-15 [Doc] Inited description syntax.
29
344ecd2d »
2012-03-20 [Doc] Described basic features of the YZ.
30 some-query
31 => some-result
e475a1bd »
2012-03-20 [Doc] Minor fixing.
32
ce147e9b »
2012-04-25 [Doc] Added mention about collq in the beggining of SYNTAX.md.
33 In some cases it may be convenient to demonstrate feature of the YZ using other collection
34 (for example collection with numbers) rather specified above collection with string.
35 So the collq function from the current implementation of the YZ is used.
36 The collq function takes two parameters (query and collection) and returns
37 result of query. Example:
38
39 ```clojure
40 (collq "some-query" some-collection)
41 => some-result
42 ```
43
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
44 <a name="selection"></a>
45 ### Selection
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
46 In order to get data from your model you can specify name of class of objects which you
a6826f0d »
2012-03-21 [Doc] Minor changes of SYNTAX.md.
47 want to get. If you want all strings you just query:
344ecd2d »
2012-03-20 [Doc] Described basic features of the YZ.
48
49 string
4a6f2c8e »
2012-03-20 [Doc] Fixed typos and errors into description of syntax.
50
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
51 and this query returns all strings from collection names:
4a6f2c8e »
2012-03-20 [Doc] Fixed typos and errors into description of syntax.
52
344ecd2d »
2012-03-20 [Doc] Described basic features of the YZ.
53 => (["Bob"] ["Alice"] [""] ["Marry"] ["Kris"] ["David"] ["Alexander"])
703fa59c »
2012-03-15 [Doc] Inited description syntax.
54
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
55 <a name="projection"></a>
7e3b2aee »
2012-03-21 [Doc] Described filtering
56 ### Projection
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
57 In case you want to get some property of objects you must specify it in square brackets:
703fa59c »
2012-03-15 [Doc] Inited description syntax.
58
344ecd2d »
2012-03-20 [Doc] Described basic features of the YZ.
59 string[empty]
60 => ([false] [false] [true] [false] [false] [false] [false])
703fa59c »
2012-03-15 [Doc] Inited description syntax.
61
4a6f2c8e »
2012-03-20 [Doc] Fixed typos and errors into description of syntax.
62 Note that access to properties depends on implementation of your ElementManager
63 (in our case it is element manager for simple collections).
a6826f0d »
2012-03-21 [Doc] Minor changes of SYNTAX.md.
64 For more details about current implementation of the YZ see [here] (https://github.com/vdim/yz/blob/master/doc/IMPLEMENTATION.md).
65
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
66 For several properties you must enumerate it through whitespace(s):
703fa59c »
2012-03-15 [Doc] Inited description syntax.
67
344ecd2d »
2012-03-20 [Doc] Described basic features of the YZ.
68 string[empty class]
69 => ([false java.lang.String] [false java.lang.String]
4a6f2c8e »
2012-03-20 [Doc] Fixed typos and errors into description of syntax.
70 [true java.lang.String] [false java.lang.String]
71 [false java.lang.String] [false java.lang.String]
72 [false java.lang.String])
703fa59c »
2012-03-15 [Doc] Inited description syntax.
73
7e3b2aee »
2012-03-21 [Doc] Described filtering
74 In order to get self object in list with properties you can refer to self
75 object due to symbol "&":
76
77 string[& empty]
78 => (["Bob" false] ["Alice" false] ["" true] ["Marry" false]
79 ["Kris" false] ["David" false] ["Alexander" false])
80
344ecd2d »
2012-03-20 [Doc] Described basic features of the YZ.
81
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
82 <a name="filtering"></a>
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
83 ### Filtering
b80e2641 »
2012-04-06 [Doc] Fixed typos.
84 In order to filter your collection due to some condition(s) through some property
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
85 you should specify your predicate after name of class before symbol "#" in parenthesis. You
86 should specify property in left part of expression then you should specify binary operation and
a5b44cd7 »
2012-03-20 [Doc] Minor changes.
87 at last right part of expression:
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
88
7054baaa »
2012-03-20 [Doc] Fixed query.
89 string#(empty = false)
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
90 => (["Bob"] ["Alice"] ["Marry"] ["Kris"] ["David"] ["Alexander"])
91
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
92 If there is possibility for definition self object directly in text
b80e2641 »
2012-04-06 [Doc] Fixed typos.
93 (it is rightly for string or numbers at least),
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
94 you can refer to self object due to symbol "&" in left side of predicate:
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
95
96 string#(& = "Bob")
97 => (["Bob"])
98
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
99 YZ supports the following operations:
a5b44cd7 »
2012-03-20 [Doc] Minor changes.
100
7e3b2aee »
2012-03-21 [Doc] Described filtering
101 * equality (=, equals to = function of Clojure or .equals method of Java):
c3c66034 »
2012-03-20 [Doc] Fixed block with codes into list.
102 <pre><code>
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
103 string#(& = "Bob")
104 => (["Bob"])
c3c66034 »
2012-03-20 [Doc] Fixed block with codes into list.
105 </code></pre>
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
106
302544cb »
2012-04-06 [Doc] Moved details about implementation from SYNTAX to IMPLEMENTATION.
107 * identical ("=="):
f38622f0 »
2012-03-21 [Doc] Fixed block with clojure code.
108
7e3b2aee »
2012-03-21 [Doc] Described filtering
109 ```clojure
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
110 (collq "long#(& = 1)" [1 2])
7e3b2aee »
2012-03-21 [Doc] Described filtering
111 => ([1])
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
112 (collq "long#(& == 1)" [1 2])
7e3b2aee »
2012-03-21 [Doc] Described filtering
113 => ([1])
114 (collq "integer#(& = 1)" [(Integer. 1) (Integer. 2)])
115 => ([1])
116 (collq "integer#(& == 1)" [(Integer. 1) (Integer. 2)])
117 => ()
118 ```
119
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
120 * >, <, >=, <= (rightly for numbers):
121
122 ```clojure
b80e2641 »
2012-04-06 [Doc] Fixed typos.
123 (collq "long#(& > 10)" [199 4 6 10 34])
7e3b2aee »
2012-03-21 [Doc] Described filtering
124 => ([34] [199])
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
125 ```
126
b80e2641 »
2012-04-06 [Doc] Fixed typos.
127 * negation ("!=" and syntax sugar "not="):
7e3b2aee »
2012-03-21 [Doc] Described filtering
128 <pre><code>
129 string#(& != "Bob")
130 => (["Alice"] [""] ["Marry"] ["Kris"] ["David"] ["Alexander"])
131 </code></pre>
132
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
133 * regex (rightly for strings):
c3c66034 »
2012-03-20 [Doc] Fixed block with codes into list.
134 <pre><code>
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
135 string#(& ~ "^.a.*")
136 => (["Marry"] ["David"])
c3c66034 »
2012-03-20 [Doc] Fixed block with codes into list.
137 </code></pre>
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
138
39c3bdba »
2012-04-03 [Doc] Fixed grammar typos.
139 * logical operation (&& and || and syntax sugar "and" and "or" respectively):
c3c66034 »
2012-03-20 [Doc] Fixed block with codes into list.
140 <pre><code>
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
141 string#(& = "Bob" || & = "Marry")
142 => (["Bob"] ["Marry"])
c3c66034 »
2012-03-20 [Doc] Fixed block with codes into list.
143 </code></pre>
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
144
7e3b2aee »
2012-03-21 [Doc] Described filtering
145 * RCP (Reduced Complicate Predicates, this technique allows to reduce text of
146 your predicates which is adjusted to same property):
c3c66034 »
2012-03-20 [Doc] Fixed block with codes into list.
147 <pre><code>
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
148 string#(& = ("Bob" || "Marry"))
149 => (["Bob"] ["Marry"])
c3c66034 »
2012-03-20 [Doc] Fixed block with codes into list.
150 </code></pre>
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
151
7e3b2aee »
2012-03-21 [Doc] Described filtering
152 * overriding binary operation in case RCP is used:
a8bb0acc »
2012-03-20 [Doc] Minor changes.
153 <pre><code>
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
154 string#(& = ("Bob" || "Mike" || ~"^.a.*"))
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
155 => (["Bob"] ["Marry"] ["David"])
a8bb0acc »
2012-03-20 [Doc] Minor changes.
156 </code></pre>
d3d3e6f9 »
2012-03-20 [Doc] Described filtering.
157
158
7e3b2aee »
2012-03-21 [Doc] Described filtering
159 The right side of predicate may contains:
160
161 * Strings
162 <pre><code>
163 string#(& = "Bob")
164 => (["Bob"])
165 </code></pre>
166
167 * Numbers (integer, real, negative):
168
169 ```clojure
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
170 (collq "long#(& = 1)" [1 2])
7e3b2aee »
2012-03-21 [Doc] Described filtering
171 => ([1])
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
172 (collq "long#(& = -1)" [1 -1 2])
7e3b2aee »
2012-03-21 [Doc] Described filtering
173 => ([-1])
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
174 (collq "long#(& = 1)" [1 2])
7e3b2aee »
2012-03-21 [Doc] Described filtering
175 => ([1])
176 (collq "long#(& = -1.1)" [-1 -2 -3 -1.1])
177 => ([-1.1])
178 ```
179
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
180 * Keywords (nil, true, false):
181
182 <pre><code>
183 string#(empty = false)
184 => (["Bob"] ["Alice"] ["Marry"] ["Kris"] ["David"] ["Alexander"])
185 string#(empty = true)
186 => ([""])
187 string#(empty = nil)
188 => (["Bob"] ["Alice"] [""] ["Marry"] ["Kris"] ["David"] ["Alexander"])
189 </code></pre>
190
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
191 <a name="sorting"></a>
f76d0231 »
2012-03-21 [Doc] Inited sorting section.
192 ### Sorting
193 In order to sort your result you should use symbols "↑" and "↓" for
39c3bdba »
2012-04-03 [Doc] Fixed grammar typos.
194 sorting by ascending and by descenting respectively:
f76d0231 »
2012-03-21 [Doc] Inited sorting section.
195
196 ↑string
197 => ([""] ["Alexander"] ["Alice"] ["Bob"] ["David"] ["Kris"] ["Marry"])
198 ↓string
199 => (["Marry"] ["Kris"] ["David"] ["Bob"] ["Alice"] ["Alexander"] [""])
200
682c8efd »
2012-03-21 [Doc] Updated the sorting section.
201 If you select property and want to sort by it you should specify sorting for
f76d0231 »
2012-03-21 [Doc] Inited sorting section.
202 properties:
203
204 string[↑empty]
205 => ([false] [false] [false] [false] [false] [false] [true])
206 string[↓empty]
207 => ([true] [false] [false] [false] [false] [false] [false])
208
682c8efd »
2012-03-21 [Doc] Updated the sorting section.
209 If you select several properties and specify sorting for each property then
210 result will be sorted by first property firstly, second property secondly and so on:
211
212
213 string[↓empty ↓&]
214 => ([true ""] [false "Marry"] [false "Kris"] [false "David"]
215 [false "Bob"] [false "Alice"] [false "Alexander"])
216 string[↓& ↓empty]
217 => (["Marry" false] ["Kris" false] ["David" false] ["Bob" false]
218 ["Alice" false] ["Alexander" false] ["" true])
219
220
f76d0231 »
2012-03-21 [Doc] Inited sorting section.
221 If you want to sort by some property, but don't select it, you should specify
222 sorting into braces before name of your class:
223
224 {↑empty}string
225 => (["Bob"] ["Alice"] ["Marry"] ["Kris"] ["David"] ["Alexander"] [""])
226 {↓empty}string
227 => ([""] ["Bob"] ["Alice"] ["Marry"] ["Kris"] ["David"] ["Alexander"])
228
682c8efd »
2012-03-21 [Doc] Updated the sorting section.
229 You can specify several properties for sorting:
230
231 {↓& ↓empty}string
232 => (["Marry"] ["Kris"] ["David"] ["Bob"] ["Alice"] ["Alexander"] [""])
233 {↑& ↓empty}string
234 => ([""] ["Alexander"] ["Alice"] ["Bob"] ["David"] ["Kris"] ["Marry"])
235 {↓empty ↑&}string
236 => ([""] ["Alexander"] ["Alice"] ["Bob"] ["David"] ["Kris"] ["Marry"])
237 {↓empty ↓&}string
238 => ([""] ["Marry"] ["Kris"] ["David"] ["Bob"] ["Alice"] ["Alexander"])
239
5957d5e8 »
2012-03-23 [Doc] Added section about calling function.
240 Also there are printed version for "↓" and "↑" symbols: "d:" and "a:"
682c8efd »
2012-03-21 [Doc] Updated the sorting section.
241 correspondingly:
242
243 a:string
244 => ([""] ["Alexander"] ["Alice"] ["Bob"] ["David"] ["Kris"] ["Marry"])
245 d:string
246 => (["Marry"] ["Kris"] ["David"] ["Bob"] ["Alice"] ["Alexander"] [""])
247
5957d5e8 »
2012-03-23 [Doc] Added section about calling function.
248
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
249 <a name="calling_function"></a>
5957d5e8 »
2012-03-23 [Doc] Added section about calling function.
250 ### Calling user function
251 YZ allows to call user function:
252
253 @(count `string')
254 => ([7])
255
256 Notes:
257
258 * Languages and calling mechanism are defined by concrete implementation of the YZ.
259 * Parameters:
260 * result of query
261 * strings
262 * numbers
263 * result of calling another function
7c0ecb92 »
2012-04-04 [Doc] Improved SYNTAX document.
264
265
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
266 <a name="removing_dupls"></a>
9fda564c »
2012-04-05 [Doc] Added "union" and "subquery" sections.
267 ### Removing duplicates:
b80e2641 »
2012-04-06 [Doc] Fixed typos.
268 Use symbol "¹" or "u:" for removing duplicates from result of query:
9fda564c »
2012-04-05 [Doc] Added "union" and "subquery" sections.
269
270 ```clojure
271 (collq "long" [1 2 1])
272 => ([1 2 1])
273 (collq "¹long" [1 2 1])
274 => ([1 2])
275 (collq "u:long" [1 2 1])
276 => ([1 2])
277 ```
278
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
279 <a name="complex_model"></a>
2c78ce5b »
2012-04-05 [Doc] Fixed SYNTAX.md
280 ## More complex model
c55b014f »
2012-04-05 [Doc] Inited "Joining" section into the SYNTAX document.
281 So far we test simple flat collection. Let's consider more complex model
282 (we choose classic example about university):
79fe7b9f »
2012-04-10 [Doc] Minor changes.
283 <br />
222027a3 »
2012-04-26 [Doc] Added "title" tag for figures.
284 <img src="https://github.com/vdim/yz/raw/master/doc/uni_model.png"
285 alt="UML class diagram for university model" title="UML class diagram for university model"/>
c55b014f »
2012-04-05 [Doc] Inited "Joining" section into the SYNTAX document.
286
2c78ce5b »
2012-04-05 [Doc] Fixed SYNTAX.md
287 We implement it (see source code [here](https://github.com/vdim/yz/blob/master/test/src/university/model))
c55b014f »
2012-04-05 [Doc] Inited "Joining" section into the SYNTAX document.
288 and create some [example] (https://github.com/vdim/yz/blob/master/test/src/ru/petrsu/nest/yz/queries/uni_bd.clj)
289 which is represented on figure below in UML object diagram notation:
290 <img src="https://github.com/vdim/yz/raw/master/doc/uni_model_object.png"
222027a3 »
2012-04-26 [Doc] Added "title" tag for figures.
291 alt="Example of university model in UML object diagram notation"
292 title="Example of university model in UML object diagram notation"/>
c55b014f »
2012-04-05 [Doc] Inited "Joining" section into the SYNTAX document.
293
b80e2641 »
2012-04-06 [Doc] Fixed typos.
294 In order to use this university model and next queries you can follow to
2c78ce5b »
2012-04-05 [Doc] Fixed SYNTAX.md
295 [this] (https://github.com/vdim/yz/blob/master/doc/TESTINGUNIMODEL.md) instruction.
296
c55b014f »
2012-04-05 [Doc] Inited "Joining" section into the SYNTAX document.
297
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
298 <a name="joining"></a>
2c78ce5b »
2012-04-05 [Doc] Fixed SYNTAX.md
299 ### Joining
79fe7b9f »
2012-04-10 [Doc] Minor changes.
300 In order to select linked objects you should use round brackets. For example, if you want to
c55b014f »
2012-04-05 [Doc] Inited "Joining" section into the SYNTAX document.
301 get all courses and its faculty you should query:
302
303 course (faculty)
304
305 This query returns the following result:
306
9fda564c »
2012-04-05 [Doc] Added "union" and "subquery" sections.
307 => ([#<Course Algebra> #<Faculty Marry>]
308 [#<Course Geometry> #<Faculty David>]
309 [#<Course Russian> #<Faculty Brian>]
310 [#<Course German> #<Faculty Brian>])}
c55b014f »
2012-04-05 [Doc] Inited "Joining" section into the SYNTAX document.
311
312 Note that so far we work with flat collection and get result as flat rows. But now
e45c776f »
2012-04-05 [Doc] Minor changes.
313 a hierarchical result may be interesting:
c55b014f »
2012-04-05 [Doc] Inited "Joining" section into the SYNTAX document.
314
9fda564c »
2012-04-05 [Doc] Added "union" and "subquery" sections.
315 => [[#<Course Algebra>
316 [[#<Faculty Marry> []]]
317 #<Course Geometry>
318 [[#<Faculty David> []]]
319 #<Course Russian>
320 [[#<Faculty Brian> []]]
321 #<Course German>
322 [[#<Faculty Brian> []]]]],
c55b014f »
2012-04-05 [Doc] Inited "Joining" section into the SYNTAX document.
323
1373ee63 »
2012-04-05 [Doc] Improved joining section.
324 In case you define the following query
325
326 course (faculty (student))
327
328 you get all courses, its faculty and for each faculty his/her students:
329
d001bfb2 »
2012-04-05 [Doc] Fixed blocks with code.
330 [[#<Course Algebra>
1373ee63 »
2012-04-05 [Doc] Improved joining section.
331 [[#<Faculty Marry>
332 [[#<Student John> [] #<Student Alexander> [] #<Student Nik> []]]]]
333 #<Course Geometry>
334 [[#<Faculty David> [[#<Student John> [] #<Student Nik> []]]]]
335 #<Course Russian>
336 [[#<Faculty Brian>
337 [[#<Student John>
338 []
339 #<Student Bob>
340 []
341 #<Student John>
342 []
343 #<Student Bob>
344 []]]]]
345 #<Course German>
346 [[#<Faculty Brian>
347 [[#<Student John>
348 []
349 #<Student Bob>
350 []
351 #<Student John>
352 []
353 #<Student Bob>
354 []]]]]]]
355
d001bfb2 »
2012-04-05 [Doc] Fixed blocks with code.
356 ([#<Course Algebra> #<Faculty Marry> #<Student John>]
357 [#<Course Algebra> #<Faculty Marry> #<Student Alexander>]
358 [#<Course Algebra> #<Faculty Marry> #<Student Nik>]
359 [#<Course Geometry> #<Faculty David> #<Student John>]
360 [#<Course Geometry> #<Faculty David> #<Student Nik>]
361 [#<Course Russian> #<Faculty Brian> #<Student John>]
362 [#<Course Russian> #<Faculty Brian> #<Student Bob>]
363 [#<Course Russian> #<Faculty Brian> #<Student John>]
364 [#<Course Russian> #<Faculty Brian> #<Student Bob>]
365 [#<Course German> #<Faculty Brian> #<Student John>]
366 [#<Course German> #<Faculty Brian> #<Student Bob>]
367 [#<Course German> #<Faculty Brian> #<Student John>]
368 [#<Course German> #<Faculty Brian> #<Student Bob>])
1373ee63 »
2012-04-05 [Doc] Improved joining section.
369
370
371 In case you want to get all courses and its faculty and students, you can define the
372 following query:
373
374 course (faculty, student)
9fda564c »
2012-04-05 [Doc] Added "union" and "subquery" sections.
375 => [[#<Course Algebra>
376 [[#<Faculty Marry> []]
377 [#<Student John> [] #<Student Alexander> [] #<Student Nik> []]]
378 #<Course Geometry>
379 [[#<Faculty David> []] [#<Student John> [] #<Student Nik> []]]
380 #<Course Russian>
381 [[#<Faculty Brian> []] [#<Student John> [] #<Student Bob> []]]
382 #<Course German>
383 [[#<Faculty Brian> []] [#<Student John> [] #<Student Bob> []]]]]
384
385 => ([#<Course Algebra> #<Faculty Marry>]
386 [#<Course Algebra> #<Student John>]
387 [#<Course Algebra> #<Student Alexander>]
388 [#<Course Algebra> #<Student Nik>]
389 [#<Course Geometry> #<Faculty David>]
390 [#<Course Geometry> #<Student John>]
391 [#<Course Geometry> #<Student Nik>]
392 [#<Course Russian> #<Faculty Brian>]
393 [#<Course Russian> #<Student John>]
394 [#<Course Russian> #<Student Bob>]
395 [#<Course German> #<Faculty Brian>]
396 [#<Course German> #<Student John>]
397 [#<Course German> #<Student Bob>])
398
399 You can apply for each entity in query action which was describe above
79fe7b9f »
2012-04-10 [Doc] Minor changes.
400 (sorting, filtering, projection, removing duplicates). Note that this operations are
401 applied to current subset of objects, not for all. For example query
1373ee63 »
2012-04-05 [Doc] Improved joining section.
402
403 course (faculty#(name="Brian"))
404
79fe7b9f »
2012-04-10 [Doc] Minor changes.
405 returns <b>all</b> courses and its faculties in case he/she has name "Brian":
1373ee63 »
2012-04-05 [Doc] Improved joining section.
406
9fda564c »
2012-04-05 [Doc] Added "union" and "subquery" sections.
407 => ([#<Course Algebra>]
408 [#<Course Geometry>]
409 [#<Course Russian> #<Faculty Brian>]
547ec347 »
2012-04-25 [Doc] Minor changes.
410 [#<Course German> #<Faculty Brian>])
1373ee63 »
2012-04-05 [Doc] Improved joining section.
411
412 In case you want to get courses which is taught with Brian, you can try:
413
414 course#(faculty.name="Brian")
9fda564c »
2012-04-05 [Doc] Added "union" and "subquery" sections.
415 => ([#<Course Russian>] [#<Course German>])
416
417
88303bb7 »
2012-04-25 [Doc] Added description of the "then" feature.
418 <a name="joining_not_result"></a>
419 ### Joining without including to result
420 Round brackets allow user to join an entity to an another entity and include objects of both
421 entities to result. In case you want to join entities, but not include one of it
422 you can use "." symbol. For example, query:
423
424 course.student
425 => ([#<Student Alexander>]
547ec347 »
2012-04-25 [Doc] Minor changes.
426 [#<Student Nik>]
427 [#<Student John>]
428 [#<Student Nik>]
429 [#<Student John>]
430 [#<Student Bob>]
431 [#<Student John>]
432 [#<Student Bob>]
433 [#<Student John>])
88303bb7 »
2012-04-25 [Doc] Added description of the "then" feature.
434
435 Some notes:
436
437 * This feature may be usefull for definition path between entities which is not
438 used by default. Let's imagine abstract object model something like represented
439 on figure below:
547ec347 »
2012-04-25 [Doc] Minor changes.
440
88303bb7 »
2012-04-25 [Doc] Added description of the "then" feature.
441 <img src="https://github.com/vdim/yz/raw/master/doc/abstract-om.png"
442 alt="Some abstract object model" title="Some abstract object model"/>
443
444 We want to select objects of the Entity1 and its objects of the Entity2 throught Entity3 and Entity4 (green path),
445 but query
446
447 entity1 (entity2)
448
449 may return results due to wrong red path (in fact it depends on implementation of the YZ, but let's suppose that
f24837d9 »
2012-04-25 [Doc] Fixed typos.
450 our implementation of the YZ returns first shortest path). In order to solve this problem you can query
88303bb7 »
2012-04-25 [Doc] Added description of the "then" feature.
451
452 entity1 (entity3.entity2)
453
454 which returns result due to right green path (first, YZ try to find path between classes Entity1 and Entity3 and
455 then between classes Entity3 and Entity2).
456
457 * "student" in above query is not property, but it is entity for which YZ tries to find path.
0d3ca586 »
2012-04-25 [Doc] Fixed problem with list in the "join_not_result" section.
458
88303bb7 »
2012-04-25 [Doc] Added description of the "then" feature.
459 If searching fails then YZ tries to recognize property and extract its value:
0d3ca586 »
2012-04-25 [Doc] Fixed problem with list in the "join_not_result" section.
460
88303bb7 »
2012-04-25 [Doc] Added description of the "then" feature.
461 course.students
462 => ([#<HashSet [Alexander, Nik, John]>]
547ec347 »
2012-04-25 [Doc] Minor changes.
463 [#<HashSet [Nik, John]>]
464 [#<HashSet [Bob, John]>]
465 [#<HashSet [Bob, John]>])
88303bb7 »
2012-04-25 [Doc] Added description of the "then" feature.
466
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
467 <a name="union"></a>
9fda564c »
2012-04-05 [Doc] Added "union" and "subquery" sections.
468 ### Union
469 In case you want to get results of several queries in single query, you
470 can use "," for union results
471
472 course, faculty
473 => ([#<Course Algebra>]
474 [#<Course Geometry>]
475 [#<Course Russian>]
476 [#<Course German>]
477 [#<Faculty Marry>]
478 [#<Faculty David>]
479 [#<Faculty Brian>]
480 [#<Faculty Bob>])
481
482 course, @(count `course')
483 => ([#<Course Algebra>]
484 [#<Course Geometry>]
485 [#<Course Russian>]
486 [#<Course German>]
487 [4])
488
489 @(count `course'), @(count `faculty'), @(count `student')
490 => ([4] [4] [4])
491
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
492 <a name="subquery"></a>
9fda564c »
2012-04-05 [Doc] Added "union" and "subquery" sections.
493 ### Subquery in right side of predicates
494 You can use YZ query in the right side of predicate of another YZ query.
495 For example you want to get students which have same name of his/her faculties:
496
497 student#(name=faculty.name)
498 => ()
499
500 Result is empty, because there is not such student. But if you want find
501 students which have same name from all university faculties, you can try:
502
503 student#(name=Ŷfaculty.name)
504 => ([#<Student Bob>])
505
506 Modificator Ŷ denotes all existing faculties (not only linked with current student). As you can note,
507 subquery returns collection and two previous queries check collection by "at least one" option. In case
508 you want check collection by "all" option, you can use modificator ∀. Examples:
509
510 student#(name != Ŷfaculty.name)
511 => ([#<Student Alexander>] [#<Student Nik>] [#<Student John>] [#<Student Bob>])
512 student#(name != Ŷ∀faculty.name)
513 => ([#<Student Alexander>] [#<Student Nik>] [#<Student John>])
514 student#(name != ∀faculty.name)
515 => ([#<Student Alexander>] [#<Student Nik>] [#<Student John>] [#<Student Bob>])
1373ee63 »
2012-04-05 [Doc] Improved joining section.
516
5c9d6caa »
2012-04-05 [Doc] Added table with typed and not-typed symbols.
517
88f0c510 »
2012-04-05 [Doc] Added table of contents to Syntax.md.
518 <a name="table_typed_notyped"></a>
5c9d6caa »
2012-04-05 [Doc] Added table with typed and not-typed symbols.
519 ## Table with typed and not typed symbols
520
521 <table>
522 <tr>
523 <td>Not typed</td>
524 <td>Typed</td>
525 <td>Note</td>
526 </tr>
527 <tr>
528 <td>↑</td>
529 <td>a:</td>
530 <td>Sort by ascending.</td>
531 </tr>
532 <tr>
533 <td>↓</td>
534 <td>d:</td>
535 <td>Sort by descending.</td>
536 </tr>
537 <tr>
538 <td>∀</td>
539 <td>all:</td>
540 <td>Check all elements from collection.</td>
541 </tr>
542 <tr>
543 <td>Ŷ</td>
544 <td>A:</td>
545 <td>Select all elements (not only linked with current object).</td>
546 </tr>
547 <tr>
548 <td>¹</td>
549 <td>u:</td>
550 <td>Remove duplicates.</td>
551 </tr>
552 </table>
Something went wrong with that request. Please try again.