doc/book/en/annexes/rql/intro.rst
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 15 Oct 2010 11:25:59 +0200
changeset 6499 c4123c741c66
parent 5953 af48c527aea7
child 7529 2fdc310be7cd
permissions -rw-r--r--
[deprecation] enhanced messages
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5189
diff changeset
     1
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5189
diff changeset
     2
.. _rql_intro:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     3
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     4
Introduction
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     5
------------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     6
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     7
Goals of RQL
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     8
~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     9
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    10
The goal is to have a semantic language in order to:
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    11
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    12
- query relations in a clear syntax
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    13
- empowers access to data repository manipulation
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    14
- making attributes/relations browsing easy
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    15
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    16
As such, attributes will be regarded as cases of special relations (in
5189
84d4587a92bc [doc/book] rql/dbapi cleanup, rip cachekey (prematurely ?)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
    17
terms of usage, the user should see no syntactic difference between an
84d4587a92bc [doc/book] rql/dbapi cleanup, rip cachekey (prematurely ?)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
    18
attribute and a relation).
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    19
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    20
Comparison with existing languages
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    21
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    22
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    23
SQL
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    24
```
2535
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    25
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    26
RQL may remind of SQL but works at a higher abstraction level (the *CubicWeb*
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    27
framework generates SQL from RQL to fetch data from relation databases). RQL is
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    28
focused on browsing relations. The user needs only to know about the *CubicWeb*
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    29
data model he is querying, but not about the underlying SQL model.
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    30
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    31
Sparql
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    32
``````
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    33
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    34
The query language most similar to RQL is SPARQL_, defined by the W3C to serve
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    35
for the semantic web.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    36
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    37
Versa
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    38
`````
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    39
2535
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    40
We should look in more detail, but here are already some ideas for the moment
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    41
... Versa_ is the language most similar to what we wanted to do, but the model
5189
84d4587a92bc [doc/book] rql/dbapi cleanup, rip cachekey (prematurely ?)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
    42
underlying data being RDF, there are some things such as namespaces or
2535
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    43
handling of the RDF types which does not interest us. On the functionality
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    44
level, Versa_ is very comprehensive including through many functions of
5189
84d4587a92bc [doc/book] rql/dbapi cleanup, rip cachekey (prematurely ?)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2535
diff changeset
    45
conversion and basic types manipulation, which we may want to look at one time
2535
c7b736929a58 [doc] a bit of rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    46
or another.  Finally, the syntax is a little esoteric.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    47
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    48
Datalog
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    49
```````
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    50
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    51
Datalog_ is a prolog derived query langage which applies to relational
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    52
databases. It is more expressive than RQL in that it accepts either
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    53
extensional_ and intensional_ predicates (or relations). As of now,
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    54
RQL only deals with intensional relations.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    55
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    56
The different types of queries
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    57
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    58
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    59
Search (`Any`)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    60
   Extract entities and attributes of entities.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    61
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    62
Insert entities (`INSERT`)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    63
   Insert new entities or relations in the database.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    64
   It can also directly create relationships for the newly created entities.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    65
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    66
Update entities, create relations (`SET`)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    67
   Update existing entities in the database,
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    68
   or create relations between existing entities.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    69
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    70
Delete entities or relationship (`DELETE`)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    71
   Remove entities or relations existing in the database.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    72
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    73
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    74
RQL relation expressions
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    75
~~~~~~~~~~~~~~~~~~~~~~~~
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    76
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    77
RQL expressions apply to a live database defined by a
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    78
:ref:`datamodel_definition`. Apart from the main type, or head, of the
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    79
expression (search, insert, etc.) the most common constituent of an
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    80
RQL expression is a (set of) relation expression(s).
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    81
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    82
An RQL relation expression contains three components:
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    83
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    84
* the subject, which is an entity type
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    85
* the predicate, which is a relation definition (an arc of the schema)
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    86
* the object, which is either an attribute or a relation to another entity
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    87
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    88
.. image:: Graph-ex.gif
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    89
    :alt: <subject> <predicate> <object>
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    90
    :align: center
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    91
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    92
.. warning::
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    93
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    94
 A relation is always expressed in the order: ``subject``,
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    95
 ``predicate``, ``object``.
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
    96
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    97
 It is important to determine if the entity type is subject or object
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    98
 to construct a valid expression. Inverting the subject/object is an
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
    99
 error since the relation cannot be found in the schema.
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
   100
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   101
 If one does not have access to the code, one can find the order by
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   102
 looking at the schema image in manager views (the subject is located
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   103
 at the beginning of the arrow).
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   104
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   105
An example of two related relation expressions::
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
   106
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   107
  P works_for C, P name N
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
   108
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   109
RQL variables represent typed entities. The type of entities is
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   110
either automatically inferred (by looking at the possible relation
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   111
definitions, see :ref:`RelationDefinition`) or explicitely constrained
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   112
using the ``is`` meta relation.
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
   113
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   114
In the example above, we barely need to look at the schema. If
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   115
variable names (in the RQL expression) and relation type names (in the
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   116
schema) are expresssively designed, the human reader can infer as much
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   117
as the |cubicweb| querier.
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
   118
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   119
The ``P`` variable is used twice but it always represent the same set
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   120
of entities. Hence ``P works_for C`` and ``P name N`` must be
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   121
compatible in the sense that all the Ps (which *can* refer to
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   122
different entity types) must accept the ``works_for`` and ``name``
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   123
relation types. This does restrict the set of possible values of P.
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
   124
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   125
Adding another relation expression::
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
   126
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   127
  P works_for C, P name N, C name "logilab"
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
   128
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   129
This further restricts the possible values of P through an indirect
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   130
constraint on the possible values of ``C``. The RQL-level unification_
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   131
happening there is translated to one (or several) joins_ at the
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   132
database level.
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
   133
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   134
.. note::
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   135
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   136
 In |cubicweb|, the term `relation` is often found without ambiguity
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   137
 instead of `predicate`.  This predicate is also known as the
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   138
 `property` of the triple in `RDF concepts`_
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   139
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   140
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   141
RQL Operators
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   142
~~~~~~~~~~~~~
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
   143
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   144
An RQL expression's head can be completed using various operators such
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   145
as ``ORDERBY``, ``GROUPBY``, ``HAVING``, ``LIMIT`` etc.
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   146
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   147
RQL relation expressions can be grouped with ``UNION`` or
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   148
``WITH``. Predicate oriented keywords such as ``EXISTS``, ``OR``,
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   149
``NOT`` are available.
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   150
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   151
The complete zoo of RQL operators is described extensively in the
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   152
following chapter (:ref:`RQL`).
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   153
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   154
.. _RDF concepts: http://www.w3.org/TR/rdf-concepts/
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5400
diff changeset
   155
.. _Versa: http://wiki.xml3k.org/Versa
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   156
.. _SPARQL: http://www.w3.org/TR/rdf-sparql-query/
5953
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   157
.. _unification: http://en.wikipedia.org/wiki/Unification_(computing)
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   158
.. _joins: http://en.wikipedia.org/wiki/Join_(SQL)
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   159
.. _Datalog: http://en.wikipedia.org/wiki/Datalog
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   160
.. _intensional: http://en.wikipedia.org/wiki/Intensional_definition
af48c527aea7 [doc/book] fix & enhance rql intro chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5924
diff changeset
   161
.. _extensional: http://en.wikipedia.org/wiki/Extension_(predicate_logic)