Permalink
Browse files

[doc] database: minor changes in the selection chapter.

  • Loading branch information...
1 parent 119cbc3 commit 4e45b1e946b0aa3005067798b80d8d4c3c118ffd @akoprow akoprow committed with BourgerieQuentin May 10, 2012
Showing with 15 additions and 12 deletions.
  1. +15 −12 opadoc/manual.omd/en/ref_database.omd
@@ -221,29 +221,32 @@ Furthermore you can specify some querying options:
intmap(stored) submap = /dbname/imap[< 9 and > 4]
Selection
---------
+---------
+
+We saw how we can query database sets and maps to obtain a sub-set of their
+values. But often we do not need all the information stored there but only
+a selected few fields and fetching complete information from the database
+would be inefficient.
-We saw how we can request database sets and maps to obtain a sub-set of declared
-dbset and map. But often we need only have a subset of fields stored at database
-rows. We already saw we can access to subpath of a given path :
+We already saw how we can access a subpath of a given path:
// Access to /my_db/r
stored x = /my_db/r
- // Access to the /y sub-path of /my_db/r
+ // Access to the /x sub-path of /my_db/r
int x = /my_db/r/x
-If we want to access to both supath /x and /y of path /my_db/r we can write
-something like that :
+If we want to access to both subpath /x and /y of path /my_db/r we can write
+something like that:
- {int x, int y} x = {x : /my_db/r/x, y : /my_db/r/y}
+ {int x, int y} xy = {x : /my_db/r/x, y : /my_db/r/y}
-But they have a more consice and optimized way to get these datas :
+But there is a more concise syntax to achieve the same:
// This path access means 'select fields x and y in path /my_db/r'
{int x, int y} x = /my_db/r.{x, y}
-Conversely, you could use these kinds of projection on database sets and maps,
-below some examples:
+Similarly, you can use these kinds of projections on database sets and maps.
+Some examples follow:
// Access of /v sub-path of a set access with primary key
string result = /dbname/set[x == 10]/v
@@ -254,7 +257,7 @@ below some examples:
// Access of /v sub-paths of a set access
dbset(string, _) results = /dbname/set[x > 10, y > 0, v in ["foo", "bar"]]/v
- // Access of both sub-paths /x and /v of a set access
+ // Access of two sub-paths /x and /v of a set access
dbset({int x, string v}, _) results = /dbname/set[x > 10, y > 0, v in ["foo", "bar"]].{x, v}

0 comments on commit 4e45b1e

Please sign in to comment.