author | Sandrine Ribeau <sandrine.ribeau@logilab.fr> |
Thu, 20 Nov 2008 10:22:44 -0800 | |
changeset 111 | 7a06f06de32f |
parent 108 | 60faaa480f02 |
permissions | -rw-r--r-- |
74
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
1 |
.. -*- coding: utf-8 -*- |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
2 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
3 |
RQL language (Relation Query Language) |
81
f5886815126b
punctuation stuff
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
74
diff
changeset
|
4 |
====================================== |
74
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
5 |
|
108
60faaa480f02
[doc] another step towards dissolving LAX book into CubicWeb book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
93
diff
changeset
|
6 |
XXXFIXME MERGE WITH 16-rql.en.txt |
60faaa480f02
[doc] another step towards dissolving LAX book into CubicWeb book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
93
diff
changeset
|
7 |
|
74
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
8 |
Introduction |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
9 |
------------ |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
10 |
* RQL language focuses on browsing relations. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
11 |
* Attributes are considered as particular relations. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
12 |
* RQL is inspired from SQL but is a high level language. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
13 |
* A good knowledge of Erudi's schemas defining the application is required. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
14 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
15 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
16 |
Types of requests |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
17 |
----------------- |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
18 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
19 |
Search (`Any`) |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
20 |
query the repository to extract entities and/or attributes. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
21 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
22 |
Insertion (`INSERT`) |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
23 |
insert new entities in the database. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
24 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
25 |
Updates of entities, creation of relations (`SET`) |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
26 |
update existing entities in the database, or create relations between existing |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
27 |
entities |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
28 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
29 |
Deletion of entities or relations (`DELETE`) |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
30 |
delete existing entities and relations from the database. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
31 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
32 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
33 |
Variables and typing |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
34 |
-------------------- |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
35 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
36 |
Entities and values to browse and/or select are set in the query through *variables* |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
37 |
which should be written in capital letters. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
38 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
39 |
The possible types for each variable can be deducted from the schema depending on |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
40 |
the conditions expressed in the query. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
41 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
42 |
You can force the possible types for a variable thanks to the special relation `is`. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
43 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
44 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
45 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
46 |
Built-in types |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
47 |
-------------- |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
48 |
* `String` (literal: between double or single quotes). |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
49 |
* `Int`, `Float` (separator is '.'). |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
50 |
* `Date`, `Datetime`, `Time` (literal: pattern YYYY/MM/DD[ hh:mm] or keywords |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
51 |
`TODAY` and `NOW`). |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
52 |
* `Boolean` (keywords `TRUE` et `FALSE`). |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
53 |
* keyword `NULL`. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
54 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
55 |
Operators |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
56 |
---------- |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
57 |
* Logical operators: `AND`, `OR`, `,`. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
58 |
* Mathematical operators: `+`, `-`, `*`, `/`. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
59 |
* Comparison operators: `=`, `<`, `<=`, `>=`, `>`, `~=`, `LIKE`, `IN`. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
60 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
61 |
* The operator `=` is the default operator. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
62 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
63 |
* The operator `LIKE` / `~=` allows the use of the character `%` in a string |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
64 |
to indicate that the string should start/end with a prefix/suffix:: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
65 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
66 |
Any X WHERE X nom ~= 'Th%' |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
67 |
Any X WHERE X nom LIKE '%lt' |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
68 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
69 |
* The operator `IN` allows to provide a list of possible values:: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
70 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
71 |
Any X WHERE X nom IN ('chauvat', 'fayolle', 'di mascio', 'thenault') |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
72 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
73 |
Search query |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
74 |
------------ |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
75 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
76 |
[`DISTINCT`] <entity type> V1(, V2)\* |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
77 |
[`GROUPBY` V1(, V2)\*] [`ORDERBY` <orderterms>] |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
78 |
[`WHERE` <condition>] |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
79 |
[`LIMIT` <value>] [`OFFSET` <value>] |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
80 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
81 |
:entity type: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
82 |
Type of the selected variable |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
83 |
Special type `Any` is equivalent to not specify a type |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
84 |
:condition: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
85 |
list of relations to browse following the pattern |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
86 |
`V1 relation V2|<static value>` |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
87 |
:orderterms: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
88 |
Setting of the selection order : variable or column number followed by the |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
89 |
sorting method (`ASC`, `DESC`), ASC being the default value. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
90 |
:note for grouped queries: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
91 |
For grouped queries (e.g. using function `GROUPBY`), all the selected |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
92 |
variables must be grouped or aggregated. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
93 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
94 |
Examples - search |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
81
diff
changeset
|
95 |
~~~~~~~~~~~~~~~~~ |
74
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
96 |
:: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
97 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
98 |
Any X WHERE X eid 53 |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
99 |
Personne X |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
100 |
Personne X WHERE X travaille_pour S, S nom "logilab" |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
101 |
Any E,COUNT(X) GROUPBY E ORDERBY EN WHERE X is E, E name EN |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
102 |
Any E,COUNT(X) GROUPBY E ORDERBY 2 WHERE X is E |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
103 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
104 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
105 |
Advanced features |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
81
diff
changeset
|
106 |
~~~~~~~~~~~~~~~~~ |
81
f5886815126b
punctuation stuff
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
74
diff
changeset
|
107 |
* Aggregate functions: `COUNT`, `MIN`, `MAX`, `SUM`. |
f5886815126b
punctuation stuff
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
74
diff
changeset
|
108 |
* String functions:`UPPER`, `LOWER`. |
f5886815126b
punctuation stuff
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
74
diff
changeset
|
109 |
* Optional relations: |
74
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
110 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
111 |
* They allow to select entities related to others or not. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
112 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
113 |
* You should use `?` behind the variable to specify the relation to itself is |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
114 |
optional. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
115 |
|
81
f5886815126b
punctuation stuff
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
74
diff
changeset
|
116 |
- Project anomalies related to a version or not:: |
74
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
117 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
118 |
Any X,V WHERE X concerns P, P eid 42, X corrected_in V? |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
119 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
120 |
- All the cards and the project they document otherwise :: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
121 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
122 |
Any C,P WHERE C is Card, P? documented_by C |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
123 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
124 |
Negation |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
81
diff
changeset
|
125 |
~~~~~~~~ |
74
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
126 |
* A query such as `Document X WHERE NOT X owned_by U` is equivalent to |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
127 |
"the documents which do not have relation `owned_by`". |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
128 |
* Whereas the query `Document X WHERE NOT X owned_by U, U login "syt"` |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
129 |
is equivalent to "the documents which do not have relation `owned_by` |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
130 |
with the user syt". They could have a relation with other users. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
131 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
132 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
133 |
Identity |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
81
diff
changeset
|
134 |
~~~~~~~~ |
74
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
135 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
136 |
We could use the special relation `identity` in a query in order to add a |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
137 |
condition of identity between two variables. This is equivalent to ``is`` |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
138 |
in Python. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
139 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
140 |
Any A WHERE A comments B, A identity B |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
141 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
142 |
returns the set of objects which comment themselves. The relation `identity` |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
143 |
is very usefull while defining security rules with `RQLExpressions`. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
144 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
145 |
Insertion queries |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
146 |
----------------- |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
147 |
`INSERT` <entity type> V1(, <entity type> V2)\* `:` <assignments> |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
148 |
[`WHERE` <condition>] |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
149 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
150 |
:assignments: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
151 |
list of relations to assign such as `V1 relation V2|<static value>` |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
152 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
153 |
The condition allow to define the variables we would use in assignments. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
154 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
155 |
Be careful, if a condition is specified, the insertion is done *for each result |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
156 |
returned by the condition*. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
157 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
158 |
Examples - insertion |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
81
diff
changeset
|
159 |
~~~~~~~~~~~~~~~~~~~~~ |
74
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
160 |
* Insertion of a new person named 'bidule':: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
161 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
162 |
INSERT Person X: X name 'bidule' |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
163 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
164 |
* Insertion of a new person named 'bidule', another named |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
165 |
'chouette' and a relation 'friend' between them:: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
166 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
167 |
INSERT Person X, Person Y: X name 'bidule', Y name 'chouette', X friend Y |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
168 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
169 |
* Insertion of a new person named 'bidule' and a relation 'friend'with an |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
170 |
existing person 'chouette':: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
171 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
172 |
INSERT Person X: X name 'bidule', X friend Y WHERE Y name 'chouette' |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
173 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
174 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
175 |
Update queries |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
176 |
-------------- |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
177 |
`SET` <assignments> |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
178 |
[`WHERE` <condition>] |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
179 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
180 |
Be careful, if a condition is specified, the update is done *for each result |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
181 |
returned by the condition*. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
182 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
183 |
Examples - update |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
81
diff
changeset
|
184 |
~~~~~~~~~~~~~~~~~ |
74
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
185 |
* Renaming of the person named 'bidule' to 'toto', with change on the first name:: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
186 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
187 |
SET X name 'toto', X firstname 'original' WHERE X is 'Person', X name 'bidule' |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
188 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
189 |
* Insertion of a relation of type 'know' between two objects linked with the relation |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
190 |
of type 'friend' :: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
191 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
192 |
SET X know Y WHERE X friend Y |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
193 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
194 |
Deletion queries |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
195 |
---------------- |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
196 |
`DELETE` (<entity type> V) | (V1 relation v2),... |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
197 |
[`WHERE` <condition>] |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
198 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
199 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
200 |
Be careful, if a condition is specified, the deletion is done *for each result |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
201 |
returned by the condition*. |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
202 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
203 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
204 |
Examples |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
81
diff
changeset
|
205 |
~~~~~~~~ |
74
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
206 |
* Deletion of the person named 'toto':: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
207 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
208 |
DELETE Person X WHERE X name 'toto' |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
209 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
210 |
* Deletion of all the relations of type 'friend' linked to the person named |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
211 |
'toto':: |
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
212 |
|
9a9fe515934d
[doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
213 |
DELETE X friend Y WHERE X is 'Person', X name 'toto' |