5 ------------ |
5 ------------ |
6 |
6 |
7 Goals of RQL |
7 Goals of RQL |
8 ~~~~~~~~~~~~ |
8 ~~~~~~~~~~~~ |
9 |
9 |
10 The goal is to have a language making relations browsing easy. As |
10 The goal is to have a semantic language in order to: |
11 such, attributes will be regarded as cases of special relations (in |
11 |
|
12 - query relations in a clear syntax |
|
13 - empowers access to data repository manipulation |
|
14 - making attributes/relations browsing easy |
|
15 |
|
16 As such, attributes will be regarded as cases of special relations (in |
12 terms of usage, the user should see no syntactic difference between an |
17 terms of usage, the user should see no syntactic difference between an |
13 attribute and a relation). |
18 attribute and a relation). |
14 |
19 |
15 Comparison with existing languages |
20 Comparison with existing languages |
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
21 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
57 |
62 |
58 Delete entities or relationship (`DELETE`) |
63 Delete entities or relationship (`DELETE`) |
59 Remove entities or relations existing in the database. |
64 Remove entities or relations existing in the database. |
60 |
65 |
61 |
66 |
|
67 Concepts |
|
68 ~~~~~~~~ |
|
69 |
|
70 Entity type |
|
71 ``````````` |
|
72 |
|
73 RQL manipulates variables that are instances of entities. |
|
74 Each entity has its own type which are used in backend to improve the query |
|
75 execution plan. |
|
76 |
|
77 Restrictions |
|
78 ```````````` |
|
79 |
|
80 They are conditions used to limit the perimeter of the result set. |
|
81 |
|
82 Relations |
|
83 ````````` |
|
84 A relation is a `3-expression` defined as follows: |
|
85 |
|
86 .. image:: Graph-ex.gif |
|
87 :alt: <subject> <predicate> <object> |
|
88 :align: center |
|
89 |
|
90 A RQL relation contains three components: |
|
91 |
|
92 * the subject, which is an entity type |
|
93 * the predicate, which is an oriented graph |
|
94 * the object, which is either an attribute or a relation to another entity |
|
95 |
|
96 In cubicweb, the term `relation` is often found without ambiguity instead of `predicate`. |
|
97 This predicate is also known as the `property` of the triple in `RDF concepts`_ |
|
98 |
|
99 A relation is always expressed in the order: subject, predicate, object. |
|
100 |
|
101 It's important to determine if entity type is subject or object to construct a |
|
102 valid expression. An inversion subject/object is equivalent to an RQL error |
|
103 since the supposed relation cannot be found in schema. If you don't have access |
|
104 to the code, you could find the order by looking at the schema image in manager |
|
105 views (the subject is located at the beginning of the arrow). |
|
106 |
|
107 .. _SQL: http://www.firstsql.com/tutor5.htm |
|
108 .. _RDF concepts: http://www.w3.org/TR/rdf-concepts/ |
|
109 |
|
110 Cardinality |
|
111 ``````````` |
|
112 XXX |
|
113 |
|
114 Cardinality is an important concept to model your business rules. |
|
115 They determine nu./tutorials/advanced/index.rst |
|
116 |
|
117 Please refer to the `datamodel definitions`_ for a deep understanding. |
|
118 |
|
119 `Relations`_ are always expressed by cardinality rules (`**` by default) |
|
120 |
|
121 .. _datamodel definitions: ./devrepo/datamodel/definition.rst |
|
122 |
|
123 Transaction |
|
124 ``````````` |
|
125 |
|
126 RQL supports notion of **transactions**; i.e. sequences of RQL statements |
|
127 without invoking security hooks of the instance's schema. |
|
128 |
|
129 When you're ready to make persistent the changes, you have to *commit* the |
|
130 modification in calling `commit()`. |
|
131 |
|
132 If an error is found (typically in raising a ValidationError), you have the |
|
133 possibility to roll back the transaction in invoking `rollback()` function; i.e |
|
134 to come back to the initial state of the transaction. |
|
135 |
|
136 Please, refer to the :ref:`Migration` chapter if you want more details. |
62 |
137 |
63 |
138 |
64 .. _Versa: http://uche.ogbuji.net/tech/rdf/versa/ |
139 |
|
140 .. _Versa: http://wiki.xml3k.org/Versa |
65 .. _SPARQL: http://www.w3.org/TR/rdf-sparql-query/ |
141 .. _SPARQL: http://www.w3.org/TR/rdf-sparql-query/ |