Graphically Querying RDF Using RDF-GL
Post on 19-Jan-2016
76 Views
Preview:
DESCRIPTION
Transcript
Graphically Querying RDF Using RDF-GL
Dutch-Belgian Database Day 2010 (DBDBD 2010)
November 22, 2010
Frederik Hogenboomfhogenboom@ese.eur.nl
Viorel Mileamilea@ese.eur.nl
Flavius Frasincarfrasincar@ese.eur.nl
Uzay Kaymakkaymak@ese.eur.nl
Erasmus University RotterdamPO Box 1738, NL-3000 DRRotterdam, the Netherlands
This talk is based on the paper RDF-GL: A SPARQL-Based Graphical Query Language for RDF. Hogenboom, F.P., Milea, D.V., Frasincar, F. & Kaymak, U. (2010). In Y. Badr, A. Abraham, A.-E. Hassanien & R. Chbeir (Eds.), Emergent Web Intelligence: Advanced Information Retrieval (Advanced Information and Knowledge Processing) (pp. 87-116). Springer London.
Introduction
• Increasing amount of information
• Querying large databases quickly and efficiently is desired
• This need is addressed by several tools and languages
• However, intuitiveness is often of less importance (expressivity over clarity)
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
2
Graphical Query Languages
• Enable users to create queries by arranging and connecting symbols on a canvas
• Build on existing textual query languages
• Abstract away from difficult syntax and hence aim to enhance intuitiveness
• Coverage of textual equivalents vs. maintaining usability
• Available for semi-structured representations such as XML, but no SPARQL-based GQL for RDF
• RDF-GL is a GQL for a SPARQL subset
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
3
RDF-GL
• Covers most SPARQL SELECT queries
• No support for:– Prologue: BASE and PREFIX– Query type: ASK, CONSTRUCT, DESCRIBE– REDUCED, FROM, NAMED, GRAPH
• However, the design of the language allows for extension
• Based on SPARQL and not on SPARQL 1.1
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
4
RDF-GL: Example (1)
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
PREFIX j.1: <http://www.daml.org/2003/09/factbook/factbook-ont#>SELECT DISTINCT ?name ?oilWHERE{ ?country j.1:localShortCountryName ?name . ?country j.1:grossDomesticProductPerCapita ?gdp . { FILTER (?gdp < 1500) . } UNION { FILTER (?gdp > 2500) . } OPTIONAL { ?country j.1:oilProvedReserves ?oil . }}ORDER BY ASC(?gdp)
5
RDF-GL: Mapping to SPARQL (1)
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
PREFIX j.1: <http://www.daml.org/2003/09/factbook/factbook-ont#>SELECT DISTINCT ?elevationWHERE{ ?country j.1:elevation ?elevation .}ORDER BY DESC(?elevation) OFFSET 5 LIMIT 4
Query type andsequence modifiers
8
RDF-GL: Mapping to SPARQL (2)
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
FILTER (?gdp > 1250) .
j.1:EthnicGroup rdfs:subClassOf ?class .
Filters
Triples
9
RDF-GL: Mapping to SPARQL (3)
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
?country j.1:highwaysTotal ?hw .{ FILTER (?hw < 20000) .}UNION{ FILTER (?hw > 150000) .}
Unions
OPTIONAL{ ?country j.1:heliports ?heli .}
Options
10
RDF-GL: Mapping to SPARQL (4)
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
?country j.1:highwaysTotal ?hw .{ FILTER (?hw < 20000) .}UNION{ FILTER (?hw > 150000) . OPTIONAL { ?country j.1:heliports ?heli . }}
Nesting
11
RDF-GL: Converting to SPARQL
• Generate default PREFIXes (RDF, RDFS, XSD, etc.)
• Determine query TYPE
• Generate WHERE clause:– Convert all arrows and their connected boxes to triples– Add triples not connected to UNIONs or OPTIONALs to
query– Add UNION and OPTIONAL circles and their children to
query recursively
• Determine ORDER BY
• Determine LIMIT and OFFSET
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
12
Experiments (1)
• Query the CIA World Factbook for countries which have an import or export to neighbors worth more than $10 billion a year
• The query needs to return:– The names of both the countries and their neighboring
trading partners– The percentages of imports and exports– Optionally the inflation rate of the neighboring partners
• Only the first 20 results are desired and should be ordered by country name (ascending)
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
15
Experiments (2)
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
PREFIX j.1: <http://www.daml.org/2003/09/factbook/factbook-ont#>SELECT DISTINCT ?nameC ?nameN ?percentExp ?percentImp ?inflationWHERE{ ?country j.1:conventionalShortCountryName ?nameC . ?country j.1:border ?border . ?border j.1:country ?neighbor . ?neighbor j.1:conventionalShortCountryName ?nameN . ?country j.1:exportPartner ?partnerExp . ?partnerExp j.1:percent ?percentExp . ?partnerExp j.1:country ?neighbor . ?country j.1:importPartner ?partnerImp . ?partnerImp j.1:percent ?percentImp . ?partnerImp j.1:country ?neighbor . { ?country j.1:imports ?imports . FILTER (?imports > 10000000000) . } UNION { ?country j.1:exports ?exports . FILTER (?exports > 10000000000) . } OPTIONAL { ?neighbor j.1:inflationRate ?inflation . }}ORDER BY ASC(?nameC) LIMIT 20
16
Experiments (4)
• The creation of RDF-GL queries is not necessarily faster than the creation of SPARQL queries
• However, the GQL and tool offer:– Overview– Easy reuse of variables– Maintenance
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
18
Order Dependency in SPARQL
• OPTIONAL is not commutative, causing problems when sharing variables in OPTIONAL clause:
• We need a binary OPTIONAL operator which is commutative and associative
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
19
SELECT ?name ?aliasWHERE{ ?x foaf:name ?name . OPTIONAL { ?x foaf:nick ?alias . } OPTIONAL { ?x foaf:mbox ?alias . }}
SELECT ?name ?aliasWHERE{ ?x foaf:name ?name . OPTIONAL { ?x foaf:mbox ?alias . } OPTIONAL { ?x foaf:nick ?alias . }}
Discussion
• AND-relationship is implicit, OR-relationship is explicit
• Issues:– No coverage for the complete SPARQL language– Determining statement order is difficult
• Solutions:– Extend language by using:
• Extra symbols
• Extra colors/shadings
• Extra shapes
– Add numbers for ordering, make use of the horizontal or vertical position of elements, etc.
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
20
Conclusions
• RDF-GL is a GQL for SPARQL
• The GQL covers a subset of SPARQL (i.e., almost all SELECT queries)
• Future work:– Implement a way to determine query order– Extend the language to include more of SPARQL, i.e., – Visualization:
• Widget size indicating importance• Lay-out algorithm
– SPARQL to RDF-GL conversion
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
21
Appendix: EBNF non-terminals (1)
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
[1] Query ::= SelectQuery[2] SelectQuery ::= ‘SELECT’ ‘DISTINCT’? ( Var+ | ‘*’
) WhereClause SolutionModifier[3] WhereClause ::= ‘WHERE’? GroupGraphPattern[4] SolutionModifier ::= OrderClause? LimitOffsetClauses?[5] LimitOffsetClauses ::= ( LimitClause OffsetClause? |
OffsetClause LimitClause? )[6] OrderClause ::= ‘ORDER’ ‘BY’ OrderCondition+[7] OrderCondition ::= ( ( ‘ASC’| ‘DESC’)
BrackettedExpression ) (Constraint | Var )
[8] LimitClause ::= ‘LIMIT’ INTEGER[9] OffsetClause ::= ‘OFFSET’ INTEGER[10] GroupGraphPattern ::= ‘{’ TriplesBlock?
( ( GraphPatternNotTriples | Filter ) ‘.’? TriplesBlock? )* ‘}’
[11] TriplesBlock ::= TriplesSameSubject ( ‘.’ TriplesBlock? )?
[12] GraphPatternNotTriples ::= OptionalGraphPattern | GroupOrUnionGraphPattern
23
Appendix: EBNF non-terminals (2)[13] OptionalGraphPattern ::= ‘OPTIONAL’ GroupGraphPattern[14] GroupOrUnionGraphPatter
n::= GroupGraphPattern ( ‘UNION’
GroupGraphPattern )*[15] Filter ::= ‘FILTER’ Constraint[16] Constraint ::= BrackettedExpression |
BuiltInCall | FunctionCall[17] FunctionCall ::= IRIref ArgList[18] ArgList ::= ( NIL ‘(’ Expression ( ‘,’
Expression )* ‘)’ )[19] TriplesSameSubject ::= VarOrTermPropertyListNotEmpty |
TriplesNode PropertyList[20] PropertyListNotEmpty ::= Verb ObjectList ( ‘;’ ( Verb
ObjectList )? )[21] PropertyList ::= PropertyListNotEmpty?[22] ObjectList ::= Object ( ‘,’ Object )*[23] Object ::= Graphmode[24] Verb ::= VarOrIRIref | ‘a’ [25] TriplesNode ::= Collection |
BlankNodePropertyList[26] BlankNodePropertyList ::= ‘[’ PropertyListNotEmpty ‘]’
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
24
Appendix: EBNF non-terminals (3)
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
[27] Collection ::= ‘(’ GraphNode+ ‘)’[28] GraphNode ::= VarOrTerm | TriplesNode[29] VarOrTerm ::= Var | GraphTerm[30] VarOrIRIref ::= Var | IRIref[31] Var ::= VAR1[32] GraphTerm ::= IRIref | RDFLiteral |
NumericLiteral | BooleanLiteral | BlankNode | NIL
[33] Expression ::= ConditionalOrExpression[34] ConditionalOrExpression ::= ConditionalAndExpression ( ‘||’
ConditionalAndExpression )*[35] ConditionalAndExpressio
n::= ValueLogical ( ‘&&’
ValueLogical )*[36] ValueLogical ::= RelationalExpression[37] RelationalExpression ::= NumericExpression ( ‘=’
NumericExpression | ‘!=’ NumericExpression | ‘<’ NumericExpression | ‘>’ NumericExpression | ‘<=’ NumericExpression | ‘>=’ NumericExpression )?
25
Appendix: EBNF non-terminals (4)[38] NumericExpression ::= AdditiveExpression[39] AdditiveExpression ::= MultiplicativeExpression ( ‘+’
MultiplicativeExpression | ‘-’ MultiplicativeExpression | NumericLiteralPositive | NumericLiteralNegative )*
[40] MultiplicativeExpression
::= UnaryExpression ( ‘*’ UnaryExpression | ‘/’ UnaryExpression )*
[41] UnaryExpression ::= ‘!’ PrimaryExpression | ‘+’ PrimaryExpression | ‘-’ PrimaryExpression | PrimaryExpression
[42] PrimaryExpression ::= BrackettedExpression | BuiltInCall | IRIrefOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var
[43] BrackettedExpression ::= ‘(’ Expression ‘)’
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
26
Appendix: EBNF non-terminals (5)[44] BuiltInCall ::= ‘STR’ ‘(’ Expression ‘)’ | ‘LANG’
‘(’ Expression ‘)’ | ‘LANGMATCHES’ ‘(’ Expression ‘,’ Expression ‘)’ | ‘DATATYPE’ ‘(’ Expression ‘)’ | ‘BOUND’ ‘(’ Var ‘)’ | ‘sameTerm’ ‘(’ Expression ‘,’ Expression ‘)’ | ‘isIRI’ ‘(’ Expression ‘)’ | ‘isURI’ ‘(’ Expression ‘)’ | ‘isBLANK’ ‘(’ Expression ‘)’ | ‘isLITERAL’ ‘(’ Expression ‘)’ | RegexExpression
[45] RegexExpression ::= RegexExpression[46] IRIrefOrFunction ::= IRIref ArgList?[47] RDFLiteral ::= String ( LANGTAG | ( ‘^^’
IRIref ) )?[48] NumericLiteral ::= NumericLiteralUnsigned |
NumericLiteralPositive | NumericLiteralNegative
[49] NumericLiteralUnsigned ::= INTEGER | DECIMAL | DOUBLE[50] NumericLiteralPositive ::= INTEGER_POSITIVE |
DECIMAL_POSITIVE | DOUBLE_POSITIVEDutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
27
Appendix: EBNF non-terminals (6)
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
[51] NumericLiteralNegative ::= INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE
[52] BooleanLiteral ::= ‘true’ | ‘false’[53] String ::= STRING_LITERAL1 | STRING_LITERAL2
| STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2
[54] IRIref ::= IRI_REF | PrefixedName[55] PrefixedName ::= PNAME_LN | PNAME_NS[56] BlankNode ::= BLANK_NODE_LABEL | ANON
28
Appendix: EBNF terminals (1)[57] IRI_REF ::= ‘<’ ( [^<>"{}|^`\]-[#x00-#x20])*
‘>’ [58] PNAME_NS ::= PN_PREFIX? ‘:’ [59] PNAME_LN ::= PNAME_NS PN_LOCAL [60] BLANK_NODE_LABEL ::= ‘_:’ PN_LOCAL [61] VAR1 ::= ‘?’ VARNAME [62] LANGTAG ::= ‘@’ [a-zA-Z]+ ( ‘-’ [a-zA-Z0-
9]+ )* [63] INTEGER ::= [0-9]+ [64] DECIMAL ::= [0-9]+ ‘.’ [0-9]* | ‘.’ [0-9]+ [65] DOUBLE ::= [0-9]+ ‘.’ [0-9]* EXPONENT | ‘.’
([0-9])+ EXPONENT | ([0-9])+ EXPONENT
[66] INTEGER_POSITIVE ::= ‘+’ INTEGER [67] DECIMAL_POSITIVE ::= ‘+’ DECIMAL [68] DOUBLE_POSITIVE ::= ‘+’ DOUBLE [69] INTEGER_NEGATIVE ::= ‘-’ INTEGER [70] DECIMAL_NEGATIVE ::= ‘-’ DECIMAL [71] DOUBLE_NEGATIVE ::= ‘-’ DOUBLE [72] EXPONENT ::= [eE] [+-]? [0-9]+ [73] STRING_LITERAL1 ::= ‘ ( ( [^#x27#x5C#xA#xD] ) | ECHAR
)* "’" Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
29
Appendix: EBNF terminals (2)[74] STRING_LITERAL2 ::= ‘"’ ( ( [^#x22#x5C#xA#xD] ) |
ECHAR )* ‘"’ [75] STRING_LITERAL_LONG1 ::= ’’’ ( ( "’" | "’’" )? ( [^’\] |
ECHAR ) )* "’’’" [76] STRING_LITERAL_LONG2 ::= ‘"""’ ( ( ‘"’ | ‘""’ )? ( [^"\] |
ECHAR ) )* ‘"""’ [77] ECHAR ::= ‘\’ [tbnrf\"’] [78] NIL ::= ‘(’ WS* ‘)’ [79] WS ::= #x20 | #x9 | #xD | #xA [80] ANON ::= ‘[’ WS* ‘]’ [81] PN_CHARS_BASE ::= [A-Z] | [a-z] | [#x00C0-#x00D6] |
[#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
[82] PN_CHARS_U ::= PN_CHARS_BASE | ‘_’
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
30
Appendix: EBNF terminals (3)[83] VARNAME ::= ( PN_CHARS_U | [0-9] )
( PN_CHARS_U | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )*
[84] PN_CHARS ::= PN_CHARS_U | ‘-’ | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
[85] PN_PREFIX ::= PN_CHARS_BASE ( ( PN_CHARS | ‘.’ )* PN_CHARS )?
[86] PN_LOCAL ::= ( PN_CHARS_U | [0-9] ) ( ( PN_CHARS | ‘.’ )* PN_CHARS )?
Dutch-Belgian Database Day 2010 (DBDBD 2010)November 22, 2010
31
top related