doc/book/en/C040-rql.en.txt
author Sandrine Ribeau <sandrine.ribeau@logilab.fr>
Thu, 11 Dec 2008 11:11:22 -0800
changeset 209 38a9c240ac64
parent 127 ae611743f5c6
child 255 5d2804b9a28c
permissions -rw-r--r--
[doc] Now uses specs from rql/doc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     2
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
     3
======================================
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
     4
RQL language (Relation Query Language)
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
     5
======================================
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
     6
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
     7
Introduction
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
     8
============
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
     9
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    10
Goals RQL
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    11
---------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    12
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    13
The goal is to have a language emphasizing the way of browsing
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    14
relations. As such, attributes will be regarded as cases of
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    15
special relations (in terms of implementation, the user
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    16
language not to see virtually no difference between an attribute and a
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    17
relation).
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    18
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    19
RQL is inspired by SQL but is the highest level. A knowledge of the 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    20
`CubicWeb` schema defining the application is necessary.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    21
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    22
Comparison with existing languages
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    23
----------------------------------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    24
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    25
SQL
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    26
```
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    27
RQL builds on the features of SQL but is at a higher level
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    28
(the current implementation of RQL generates SQL). For that it is limited
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    29
to the way of browsing relations and introduces variables. 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    30
The user does not need to know the model underlying SQL, but the `CubicWeb` 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    31
scheam defining the application.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    32
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    33
Versa
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    34
`````
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    35
Should I look in more detail, but here is already some ideas for
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    36
the moment ... Versa_ is the language most similar to what we wanted
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    37
to do, but the model underlying data being RDF, there is some
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    38
number of things such as namespaces or handling of the RDF types which 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    39
does not interest us. On the functionality level, Versa_ is very comprehensive
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    40
including through many functions of conversion and basic types manipulation,
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    41
which may need to be guided at one time or another. 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    42
Finally, the syntax is a little esoteric.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    43
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    44
See also
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    45
``````````
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    46
RDFQL_
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    47
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    48
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    49
The different types of queries
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    50
------------------------------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    51
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    52
Search ( `Any`)
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    53
   This type of query can extract entities and attributes of entities.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    54
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    55
Inserting entities ( `INSERT`)
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    56
   This type of query is used to insert new entities in the database. It
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    57
   will also create direct relationships entities newly created.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    58
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    59
Update entities, relations creation( `SET`)
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    60
   This type of query updates existing entities in the database,
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    61
   or create relations between existing entities.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    62
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    63
Deletion of entities or relationship ( `DELETE`)
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    64
   This type of query allows for the removal of entities and relations existing
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    65
   in the database.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    66
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    67
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    68
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    69
Examples
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    70
========
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    71
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    72
(see the tutorial: ref: `tutorielRQL` for more examples)
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    73
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    74
Search Query
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    75
------------
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    76
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    77
   [ `DISTINCT`] <entity type> V1 (V2) \ *
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    78
   [ `GROUPBY` V1 (V2) \*] [ `ORDERBY` <orderterms>]
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    79
   [ `WHERE` <restriction>]
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    80
   [ `LIMIT` <value>] [ `OFFSET` <value>]
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    81
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    82
:entity type:
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    83
   Type of selected variables.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    84
   The special type `Any` is equivalent to not specify a type.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    85
:restriction:
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    86
   list of relations to go through whic follow the pattern
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    87
     `V1 relation V2 | <static value>`
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    88
:orderterms:
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    89
   Definition of the selection order: variable or column number followed by
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    90
   sorting method ( `ASC`, `DESC`), ASC is the default.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    91
:note for grouped queries:
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    92
   For grouped queries (e.g., a clause `GROUPBY`), all
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    93
   selected variables must be aggregated or grouped.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    94
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    95
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    96
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    97
- *Search for the object of identifier 53*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    98
   ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    99
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   100
        Any WHERE X
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   101
        X eid 53
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   102
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   103
- *Search material such as comics, owned by syt and available*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   104
   ::
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   105
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   106
        WHERE X Document
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   107
        X occurence_of F, F class C, C name 'Comics'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   108
        X owned_by U, U login 'syt'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   109
        X available true
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   110
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   111
- *Looking for people working for eurocopter interested in training*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   112
   ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   113
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   114
        Person P WHERE
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   115
        P work_for P, S name 'Eurocopter'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   116
        P interested_by T, T name 'training'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   117
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   118
- *Search note less than 10 days old written by jphc or ocy*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   119
   ::
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   120
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   121
        Note N WHERE
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   122
        N written_on D, D day> (today -10),
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   123
        N written_by P, P name 'jphc' or P name 'ocy'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   124
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   125
- *Looking for people interested in training or living in Paris*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   126
   ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   127
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   128
        Person P WHERE
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   129
        (P interested_by T, T name 'training') or
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   130
        (P city 'Paris')
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   131
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   132
- *The name and surname of all people*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   133
   ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   134
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   135
        Any N, P WHERE
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   136
        X is Person, X name N, X first_name P
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   137
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   138
   Note that the selection of several entities generally force
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   139
   the use of "Any" because the type specification applies otherwise
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   140
   to all the selected variables. We could write here
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   141
   ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   142
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   143
        String N, P WHERE
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   144
        X is Person, X name N, X first_name P
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   145
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   146
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   147
Insertion query
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   148
---------------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   149
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   150
    `INSERT` <entity type> V1 (, <entity type> V2) \ * `:` <assignments>
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   151
    [ `WHERE` <restriction>]
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   152
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   153
: assignments:
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   154
   list of relations to assign in the form `V1 relationship V2 | <static value>`
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   155
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   156
The restriction can define variables used in assignments.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   157
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   158
Caution, if a restriction is specified, the insertion is done for 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   159
*each line results returned by the restriction*.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   160
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   161
- *Insert a new person named 'foo'*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   162
   ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   163
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   164
        INSERT Person X: X name 'widget'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   165
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   166
- *Insert a new person named 'foo', another called 'nice' and a 'friend' relation
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   167
  between them*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   168
  ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   169
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   170
        INSERT Person X, Person Y: X name 'foo', Y name 'nice', X friend Y
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   171
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   172
- *Insert a new person named 'foo' and a 'friend' relation with an existing 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   173
  person called 'nice'*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   174
  ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   175
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   176
        INSERT Person X: X name 'foo', X friend  Y WHERE name 'nice'
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   177
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   178
Update and relation creation queries
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   179
------------------------------------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   180
    `SET` <assignements>
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   181
    [ `WHERE` <restriction>]
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   182
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   183
Caution, if a restriction is specified, the update is done *for
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   184
each line results returned by the restriction*.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   185
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   186
- *Renaming of the person named 'foo' to 'bar' with the first name changed*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   187
  ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   188
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   189
        SET X name 'bar', X first_name 'original' where X is Person X name 'foo'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   190
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   191
- *Insert a relation of type 'know' between objects linked by 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   192
  the relation of type 'friend'*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   193
  ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   194
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   195
        SET X know Y  WHERE X friend Y
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   196
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   197
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   198
Deletion query
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   199
--------------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   200
    `DELETE` (<entity type> V) | (V1 relation v2 ),...
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   201
    [ `WHERE` <restriction>]
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   202
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   203
Caution, if a restriction is specified, the deletion is made *for
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   204
each line results returned by the restriction*.
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   205
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   206
- *Deletion of the person named 'foo'*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   207
  ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   208
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   209
        DELETE Person X WHERE X name 'foo'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   210
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   211
- *Removal of all relations of type 'friend' from the person named 'foo'*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   212
  ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   213
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   214
        DELETE X friend Y WHERE X is Person, X name 'foo'
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   215
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   216
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   217
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   218
Language definition
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   219
===================
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   220
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   221
Reserved keywords
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   222
-----------------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   223
The keywords are not case sensitive.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   224
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   225
::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   226
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   227
     DISTINCT, INSERT, SET, DELETE,
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   228
     WHERE, AND, OR, NOT
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   229
     IN, LIKE,
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   230
     TRUE, FALSE, NULL, TODAY, NOW
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   231
     GROUPBY, ORDERBY, ASC, DESC
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   232
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   233
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   234
Variables and Typing
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   235
--------------------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   236
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   237
With RQL, we do not distinguish between entities and attributes. The
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   238
value of an attribute is considered an entity of a particular type (see
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   239
below), linked to one (real) entity by a relation called the name of
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   240
the attribute.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   241
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   242
Entities and values to browse and/or select are represented in
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   243
the query by *variables* that must be written in capital letters.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   244
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   245
There is a special type **Any**, referring to a non specific type.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   246
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   247
We can restrict the possible types for a variable using the
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   248
special relation **is**.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   249
The possible type(s) for each variable is derived from the schema
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   250
according to the constraints expressed above and thanks to the relations between
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   251
each variable.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   252
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   253
Built-in types
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   254
``````````````
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   255
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   256
The base types supported are string (between double or single quotes),
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   257
integers or floats (the separator is the'.'), dates and
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   258
boolean. We expect to receive a schema in which types String,
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   259
Int, Float, Date and Boolean are defined.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   260
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   261
* `String` (literal: between double or single quotes).
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   262
* `Int`, `Float` (separator being'.').
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   263
* `Date`, `Datetime`, `Time` (literal: string YYYY/MM/DD [hh:mm] or keywords
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   264
   `TODAY` and `NOW`).
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   265
* `Boolean` (keywords `TRUE` and `FALSE`).
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   266
* `Keyword` NULL.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   267
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   268
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   269
Operators
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   270
---------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   271
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   272
Logical Operators
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   273
```````````````````
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   274
::
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   275
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   276
     AND, OR, ','
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   277
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   278
',' is equivalent to 'AND' but with the smallest among the priority
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   279
of logical operators (see :ref:`PriorityOperators`).
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   280
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   281
Mathematical Operators
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   282
``````````````````````
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   283
::
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   284
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   285
     +, -, *, /
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   286
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   287
Comparison operators
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   288
````````````````````
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   289
::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   290
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   291
     =, <, <=, >=, > = ~, IN, LIKE
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   292
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   293
* The operator `=` is the default operator.
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   294
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   295
* The operator `LIKE` equivalent to `~=` can be used with the
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   296
  special character `%` in a string to indicate that the chain 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   297
  must start or finish by a prefix/suffix:
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   298
  ::
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   299
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   300
     Any X WHERE X name =~ 'Th%'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   301
     Any X WHERE X name LIKE '%lt'
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   302
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   303
* The operator `IN` provides a list of possible values:
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   304
  ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   305
  
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   306
    Any X WHERE X name IN ( 'chauvat', 'fayolle', 'di mascio', 'thenault')
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   307
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   308
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   309
XXX nico: A trick <> 'bar' would not it be more convenient than NOT A
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   310
trick 'bar'?
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   311
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   312
.. _PriorityOperators:
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   313
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   314
Operators priority
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   315
``````````````````
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   316
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   317
1. '*', '/'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   318
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   319
2. '+', '-'
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   320
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   321
3. 'and'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   322
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   323
4. 'or'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   324
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   325
5. ','
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   326
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   327
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   328
Advanced Features
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   329
-----------------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   330
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   331
Functions aggregates
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   332
````````````````````
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   333
::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   334
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   335
     COUNT, MIN, MAX, AVG, SUM
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   336
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   337
Functions on string
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   338
```````````````````
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   339
::
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   340
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   341
     UPPER, LOWER
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   342
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   343
Optional relations
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   344
``````````````````
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   345
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   346
* They allow you to select entities related or not to another.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   347
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   348
* You must use the `?` behind the variable to specify that the relation
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   349
  toward it is optional:
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   350
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   351
   - Anomalies of a project attached or not to a version ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   352
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   353
       Any X, V WHERE X concerns P, P eid 42, X corrected_in V?
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   354
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   355
   - All cards and the project they document if necessary ::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   356
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   357
       Any C, P WHERE C is Card, P? documented_by C
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   358
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   359
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   360
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   361
BNF grammar
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   362
-----------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   363
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   364
The terminal elements are in capital letters, non-terminal in lowercase.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   365
The value of the terminal elements (between quotes) is a Python regular
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   366
expression.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   367
::
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   368
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   369
     statement:: = (select | delete | insert | update) ';'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   370
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   371
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   372
     # select specific rules
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   373
     select      ::= 'DISTINCT'? E_TYPE selected_terms restriction? group? sort?
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   374
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   375
     selected_terms ::= expression ( ',' expression)*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   376
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   377
     group       ::= 'GROUPBY' VARIABLE ( ',' VARIABLE)*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   378
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   379
     sort        ::= 'ORDERBY' sort_term ( ',' sort_term)*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   380
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   381
     sort_term   ::=  VARIABLE sort_method =?
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   382
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   383
     sort_method ::= 'ASC' | 'DESC'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   384
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   385
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   386
     # delete specific rules
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   387
     delete ::= 'DELETE' (variables_declaration | relations_declaration) restriction?
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   388
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   389
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   390
     # insert specific rules
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   391
     insert ::= 'INSERT' variables_declaration ( ':' relations_declaration)? restriction?
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   392
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   393
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   394
     # update specific rules
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   395
     update ::= 'SET' relations_declaration restriction
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   396
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   397
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   398
     # common rules
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   399
     variables_declaration ::= E_TYPE VARIABLE (',' E_TYPE VARIABLE)*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   400
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   401
     relations_declaration ::= simple_relation (',' simple_relation)*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   402
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   403
     simple_relation ::= VARIABLE R_TYPE expression
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   404
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   405
     restriction ::= 'WHERE' relations
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   406
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   407
     relations   ::= relation (LOGIC_OP relation)*
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   408
                   | '(' relations')'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   409
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   410
     relation    ::= 'NOT'? VARIABLE R_TYPE COMP_OP? expression
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   411
                   | 'NOT'? R_TYPE VARIABLE 'IN' '(' expression (',' expression)* ')'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   412
                   
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   413
     expression  ::= var_or_func_or_const (MATH_OP var_or_func_or_const) *
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   414
                   | '(' expression ')'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   415
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   416
     var_or_func_or_const ::= VARIABLE | function | constant
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   417
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   418
     function    ::= FUNCTION '(' expression ( ',' expression) * ')'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   419
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   420
     constant    ::= KEYWORD | STRING | FLOAT | INT
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   421
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   422
     # tokens
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   423
     LOGIC_OP ::= ',' | 'GOLD' | 'AND'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   424
     MATH_OP  ::= '+' | '-' | '/' | '*'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   425
     COMP_OP  ::= '>' | '>=' | '=' | '<=' | '<' | '~=' | 'LIKE'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   426
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   427
     FUNCTION ::= 'MIN' | 'MAX' | 'SUM' | 'AVG' | 'COUNT' | 'upper' | 'LOWER'
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   428
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   429
     VARIABLE ::= '[A-Z][A-Z0-9]*'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   430
     E_TYPE   ::= '[A-Z]\w*'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   431
     R_TYPE   ::= '[a-z_]+'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   432
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   433
     KEYWORD  ::= 'TRUE' | 'FALSE' | 'NULL' | 'TODAY' | 'NOW'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   434
     STRING   ::= "'([^'\]|\\.)*'" |'"([^\"]|\\.)*\"'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   435
     FLOAT    ::= '\d+\.\d*'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   436
     INT      ::= '\d+'
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   437
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   438
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   439
Remarks
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   440
-------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   441
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   442
Sorting and groups
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   443
``````````````````
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   444
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   445
- For grouped queries (e.g. with a GROUPBY clause), all
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   446
  selected variables should be grouped.
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   447
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   448
- To group and/or sort by attributes, we can do: "X,L user U, U
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   449
  login L GROUPBY L, X ORDERBY L"
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   450
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   451
- If the sorting method (SORT_METHOD) is not specified, then the sorting is
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   452
  ascendant.
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   453
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   454
Negation
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   455
````````
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   456
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   457
* A query such as `Document X WHERE NOT X owned_by U` means "the
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   458
  documents have no relation `owned_by`".
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   459
* But the query `Document X WHERE NOT X owned_by U, U login "syt"`
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   460
  means "the documents have no relation `owned_by` with the user
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   461
  syt". They may have a relation "owned_by" with another user.
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   462
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   463
Identity
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   464
````````
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   465
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   466
You can use the special relation `identity` in a query to 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   467
add an identity constraint between two variables. This is equivalent
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   468
to ``is`` in python::
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   469
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   470
   Any A WHERE A comments B, A identity B
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   471
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   472
return all objects that comment themselves. The relation
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   473
`identity` is especially useful when defining the rules for securities
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   474
with `RQLExpressions`.
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   475
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   476
Implementation
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   477
==============
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   478
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   479
Internal representation (syntactic tree)
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   480
----------------------------------------
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   481
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   482
The tree research does not contain the selected variables 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   483
(e.g. there is only what follows "WHERE").
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   484
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   485
The insertion tree does not contain the variables inserted or relations
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   486
defined on these variables (e.g. there is only what follows "WHERE").
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   487
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   488
The removal tree does not contain the deleted variables and relations
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   489
(e.g. there is only what follows the "WHERE").
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   490
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   491
The update tree does not contain the variables and relations updated
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   492
(e.g. there is only what follows the "WHERE").
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   493
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   494
::
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   495
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   496
     Select         ((Relationship | And | Gold)?, Group?, Sort?)
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   497
     Insert         (Relations | And | Gold)?
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   498
     Delete         (Relationship | And | Gold)?
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   499
     Update         (Relations | And | Gold)?
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   500
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   501
     And            ((Relationship | And | Gold), (Relationship | And | Gold))
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   502
     Or             ((Relationship | And | Gold), (Relationship | And | Gold))
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   503
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   504
     Relationship   ((VariableRef, Comparison))
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   505
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   506
     Comparison     ((Function | MathExpression | Keyword | Constant | VariableRef) +)
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   507
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   508
     Function       (())
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   509
     MathExpression ((MathExpression | Keyword | Constant | VariableRef), (MathExpression | Keyword | Constant | VariableRef))
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   510
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   511
     Group          (VariableRef +)
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   512
     Sort           (SortTerm +)
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   513
     SortTerm       (VariableRef +)
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   514
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   515
     VariableRef    ()
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   516
     Variable       ()
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   517
     Keyword        ()
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   518
     Constant       ()
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   519
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   520
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   521
Remarks
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   522
-------
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   523
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   524
- The current implementation does not support linking two relations of type
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   525
  'is' with a OR. I do not think that the negation is  supported on this type 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   526
  of relation (XXX FIXME to be confirmed).
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   527
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   528
- Relations defining the variables must be left to those using them. 
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   529
  For example::
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   530
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   531
     Point P where P abs X, P ord Y, P value X+Y
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   532
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   533
   is valid, but::
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   534
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   535
     Point P where P abs X, P value X+Y, P ord Y
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   536
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   537
   is not.
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   538
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   539
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   540
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   541
Conclusion
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   542
==========
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   543
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   544
Limitations
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   545
-----------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   546
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   547
It lacks at the moment:
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   548
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   549
- COALESCE
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   550
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   551
- restrictions on groups (HAVING)
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   552
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   553
and certainly other things ...
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   554
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   555
A disadvantage is that to use this language we must know the
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   556
format used (with real relation names and entities, not those viewing
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   557
in the user interface). On the other hand, we can not really bypass
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   558
that, and it is the job of a user interface to hide the RQL.
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   559
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   560
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   561
Topics
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   562
------
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   563
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   564
It would be convenient to express the schema matching
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   565
relations (non-recursive rules)::
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   566
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   567
     Document class Type <-> Document occurence_of Fiche class Type
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   568
     Sheet class Type    <-> Form collection Collection class Type
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   569
    
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   570
Therefore 1. becomes::
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   571
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   572
     Document X where
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   573
     X class C, C name 'Cartoon'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   574
     X owned_by U, U login 'syt'
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   575
     X available true
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   576
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   577
I'm not sure that we should handle this at RQL level ...
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   578
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   579
There should also be a special relation 'anonymous'.
115
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   580
4b66ad23fbd1 [doc] merge old lax book with the rest
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   581
209
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   582
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   583
.. _Versa: Http://uche.ogbuji.net/tech/rdf/versa/
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   584
.. _RDFQL: Http://www.w3.org/TandS/QL/QL98/pp/rdfquery.html
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   585
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   586
38a9c240ac64 [doc] Now uses specs from rql/doc
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   587
XXX see also RQL documentation in source rql/doc.