Doc­u­men­ta­tion/Graph Query Language

SELECT

FROM type_list
SELECT * | selection_list
[WHERE where_condition]
[GROUP BY group_expr]
[ORDER BY order_expr]
[LIMIT  limit_expr]
[OFFSET offset_expr]
[DEPTH  depth_expr]


type_list

type reference
  • Spec­ify the type object to be selected
  • For exam­ple a type list could be ‘User U’, ‘Car C’, …


type

name
  • A valid type in the database


ref­er­ence

name
  • A ref­er­ence for a type


selection_list

selection_list_element [, selection_list_element]
  • Con­tains the attrib­utes that need to be selected from the type
  • All attrib­utes can be selected by using the symbol ‘*’
  • Spe­cific attrib­utes can be given by using a comma seper­ated list
  • FROM Object o SELECT o.Name, o.Age” → will return only the attrib­utes “Name” and “Age”
  • FROM Object o SELECT *” → will return everything


selection_list_element

selection_source aliasopt
  • A selec­tion list ele­ment is one part of the selec­tion list
  • It can be aggre­gated using an aggre­gate func­tion and
  • It can be fol­lowed by an optional alias


selection_source

aggregate | func_call | reference.id
  • An selection_source could be an aggre­gate, a func­tion call or a sim­ple an id.


id

identifier.identifier [, identifier.identifier]
  • An id is com­posed by an iden­ti­fier a dot and a sec­ond iden­ti­fier – or a list of them.
  • An id could be ‘U.Name’ or ‘U.Friends.Age’.


iden­ti­fier

name
  • An iden­ti­fi­ca­tion name, for exam­ple the name of an type and an object attribute
  • User.Name is an id of two iden­ti­fiers for an attribut­e­name ‘Name’ of a type ‘User’,


aggre­gate

aggregate_name ( aggregate_argument )
  • An aggre­gate coun­tains an aggre­gate name and an argument.


aggregate_name

COUNT | AVG | MIN | MAX | SUM
  • An aggre­gate can be a COUNT an AVG an MIN an MAX or a SUM.
  • COUNT” will return the num­ber of ele­ments, e.g. a user has 3 friends then is the result of the query ‘COUNT(U.Friends)’ will be equals ‘3’.
  • AVG” cal­cu­lates the aver­age of the given numeric elements.
  • SUM” will return the sum of the given numeric elements.
  • MIN”/”MAX” will return the min­i­mal or max­i­mal value of a list of val­ues, e.g. ‘MAX(U.Friends.Age)’.
  • It is pos­si­ble to extent the list of aggre­gate func­tion by imple­ment­ing a data­base plug-in.


aggregate_argument

expression


expres­sion

term | unary_expression | binary_expression


term

id | string_literal | number | func_call | aggregate | tuple | tuple_set | partial_select_statement


tuple

( expression_list )


expression_list

expression [, expression]


tuple_set

[ expression_list ]
  • IMPORTANT: the square brack­ets are not optional


partial_select_statement

( select_statement )


unary_expression

unary_operator term


unary_operator

NOT | ++ | -- | ~


binary_expression

expression binary_operator expression
  • A binary expres­sion is an expres­sion which takes two argu­ments and com­bines them with a binary operator.


binary_operator

+ | - | * | / | % | & | | | ^ | = | > | < | >= | <= | <> | != | !< | !> | AND | OR | LIKE | NOT LIKE | IN | NOTIN


func_call

function_name ( function_arguments )
  • A func­tion call con­tains a func­tion name fol­lowed by the func­tion argu­ments in brackets.


function_name

CONCAT | TOUPPER | MAXWEIGHT | SUBSTRING | TOP | CURRENTDATE
  • CONCAT(STRING, STRING)” returns the con­cate­na­tion of two argu­ments of type string.
  • TOUPPER(STRING)” returns the given string con­verted to all upper­case characters
  • CURRENTDATE()” returns the cur­rent time stamp.
  • SUBSTRING(STRING, START, END) return an sub­tring of an given string value 
  • TOP(LIST)” returns the first value of a list of values.
  • MAXWEIGHT(WEIGHTETLIST)” returns the high­est weight of an weightet list.


function_arguments

expression_list


alia­sopt

EMPTY | AS aliasopt_name
  • An alia­sopt can be empty or an expres­sion which starts with the key­word AS fol­lowed by an name.
  • For exam­ple ‘U.Name AS Name’ → ‘Name’ is the alias for ‘U.Name’.


aliasopt_name

name| string_literal


where_condition

EMPTY | WHERE expression
  • The ‘WHERE’ con­di­tion, if given, includes the con­di­tions that an attribute must sat­isfy to be selected
  • For exam­ple the exist­ing users are Burns, Crow­ley, Simp­son and the query ‘FROM User U SELECT U.Name WHERE U.Name = ‘Simp­son’ ‘ will return all users with the attribute ‘name’ set to ‘Simpson’


group_expression

EMPTY | GROUP BY id_list having_condition
  • The group by expres­sion groups the result of the query by the given attribute
  • For exam­ple the fol­low­ing query groups the result by the attribute ‘name’, e.g. ‘FROM User U SELECT U.Name, COUNT(U.Age) GROUP BY U.Name’


having_condition

EMPTY | HAVING expression
  • The hav­ing con­di­tion ref­er­ences the attrib­utes which are selected in the group expression
  • The result con­tains the attrib­utes which sat­isfy the given con­di­tion / expres­sion, e.g. ‘FROM User U SELECT U.Name, COUNT(U.Age) GROUP BY U.Name HAVING COUNT(U.Age) > 3’


id_list

reference.id [, reference.id]
  • Is a sim­ple id or a list of id’s


order_expression

EMPTY | ORDER BY order_attribute_list order_attribute_direction
  • The order expres­sion returns the result in an sorted order
  • For exam­ple the result of the query ‘FROM User U SELECT U.Name, U.Age AS ‘The Age’ ORDER BY U.Name, ‘The Age’’ is sorted by the attribute ‘name’


order_attribute_list

reference.id | string_literal


order_attribute_direction

EMPTY | ASC | DESC
  • If the query has an given order_expression you can give a sort­ing direction
  • the results either sorted ascend with the key­word ASC or descend with the key­word DESC


limit_expression

EMPTY | LIMIT number
  • The limit expres­sion returns only the given num­ber of objects
  • For exam­ple ‘FROM User U SELECT U.Name LIMIT 10’ returns only 10 name attributes


offset_ expres­sion

EMPTY | OFFSET number
  • If an off­set is set then the result con­tains the objects start­ing with the given number
  • For exam­ple ‘FROM User U SELECT U.Name OFFSET 2’ return all results start­ing with the third result


depth_expr

EMPTY | DEPTH number
  • Set the resso­lu­tion depth for an result
  • For exam­ple if the depth is set to 2 and the attribute ‘friends’ is selected of an user object, then you get the friends of the friends → ‘FROM User U SELECT * DEPTH 2’
  • Default-Depth is set to 0