SPARQL Query Language Learning Abstract

Source: Internet
Author: User

SPARQL query language for RDF

Contents

* 1. Invalid duction
* 2. Making simple queries
* 3. RDF term constraints
* 4. SPARQL syntax (syntax)
O 4.1 IRIS (URIs)
O 4.2 syntax for literals
O 4.3 query the syntax of a Variable
O 4.4 blank node syntax
O 4.5 triples model syntax
O 4.6-Object List
O 4.7 Object List
O 4.8 compound list
O 4.9 RDF set
O 4.10 when the RDF: type is a predicate, it can be replaced by.
* 5. Graph patterns (Mode)
O 5.1 group graph patterns
O 5.2 empty group Pattern
O 5.3 scope of filters filtering range
* 6. including optional values (optional)
* 7. match one of the two matching alternatives
* 8. RDF dataset data set
* 9. Sort results and modify solution sequences and modifiers
O repeated results duplicate soulution
* 10. query forms
* 11. Test Value: testing values
O operand data type openrand Data Types
O filter rating filter Evaluation
* 12. SPARQL defines definition of SPARQL
O rdf terms (TERM)

1. Billing duction

* Turtle data format (tutle Data Format)

2. Making simple queries

Simple query:

Select? Title
Where
{
<Http://example.org/book/book1> }

Building RDF graphs, replace select with construct:

Construct {? X foaf: Name? Name}
Where {? X org: employeename? Name}

3. RDF term constraints

Regular Expression Filter filter RegEx ():

Prefix DC: Select? Title
Where {? X dc: title? Title
Filter RegEx (? Title, "Web", "I ")
}

4. SPARQL syntax (syntax)
4.1 IRIS (URIs)

Different representations of the same Siri:

<Http://example.org/book/book1>

Base <Book1>

Prefix book: Book: book1

4.2 syntax for literals
4.3 query the syntax of a Variable

'? ',' $ 'Are equivalent

4.4 blank node syntax

[: P "v"].
[]: P "V ".
_: B57: P "v". // The _: Label added in front
[: P "v"]: Q "W". // blank node combination

Simple blank node:

[Foaf: Name? Name;
Foaf: mbox <mailto: alice@example.org>]

4.5 triples model syntax

Prefix DC: Prefix:

Select $ title
Where {: book1 DC: Title $ title}

4.6 Object List

? X foaf: Name? Name;
Foaf: mbox? Mbox.

4.7 Object List

? X foaf: Nick "Alice", "Alice _".

4.8 compound list

? X foaf: Name? Name; foaf: Nick "Alice", "Alice _".

It is equivalent:

? X foaf: Name? Name.
? X foaf: Nick "Alice ".
? X foaf: Nick "Alice _".

4.9 RDF set

(1? X 3 4): p "W ".

4.10 when the RDF: type is a predicate, it can be replaced by.

? X a: class1.

5. Graph patterns (Mode)
5.1 group graph patterns

Prefix foaf: Select? Name? Mbox
Where {
? X foaf: Name? Name.
? X foaf: mbox? Mbox.
}

5.2 empty group Pattern

{}
Select? X where {}

5.3 scope of filters filtering range

Filter RegEx (? Name, "Smith ")

6. including optional values (optional)

Optional pattern matching

Where {? X foaf: Name? Name.
Optional {? X foaf: mbox? Mbox}
}

Constraints in optional pattern matching

Select? Title? Price
Where {? X dc: title? Title.
Optional {? X ns: Price? Price. Filter (? Price <30 )}
}

Multiple optional graph patterns

Select? Name? Mbox? Hpage
Where {? X foaf: Name? Name.
Optional {? X foaf: mbox? Mbox }.
Optional {? X foaf: homepage? Hpage}
}

7. match one of the two matching alternatives

Union:

Select? X? Y
Where {{? Book dc10: title? X} Union {? Book dc11: title? Y }}

8. RDF dataset data set

Query Information in Multiple Graphs
9. Sort results and modify solution sequences and modifiers

Sort order:

Select? Name
Where {? X foaf: Name? Name}
Order? Name

Ing projection
Duplicate result duplicate soulution

Unique distinct:

Prefix foaf: Select distinct? Name where {? X foaf: Name? Name}

Simplified forced CED:

Prefix foaf: Select reduced? Name where {? X foaf: Name? Name}

Offset offset, limit:

Select? Name
Where {? X foaf: Name? Name}
Order? Name
Limit 5
Offset 10

10. query forms

*

Select

Returns all, or a subset of, the variables bound in a query pattern match.

*

Construct

Returns an RDF graph constructed by substituting variables in a set of triple templates.

*

Ask

Returns a Boolean indicating whether a query pattern matches or not.

*

Describe

Returns an RDF graph that describes the resources found.

11. Test Value: testing values
Operand data type openrand Data Types

* XSD: integer
* XSD: decimal
* XSD: Float
* XSD: double
* XSD: String
* XSD: Boolean
* XSD: datetime

Filter evaluation filter Evaluation
A B a | B a & B
T
T f
F t f
F
T e
E t e
F E F
E F
E
12. SPARQL definition Definition of SPARQL
RDF terms (TERM)

RDF term:

RDF
Let I be the set of all Iris. Let RDF-L be the set of all RDF literals let RDF-B be the set of all blank nodes in RDF Graphs

View document source. generated on: 2008-04-17 UTC. generated by docutils from restructuredtext source.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.