Learning SPARQL, 2nd Edition

Book description

Gain hands-on experience with SPARQL, the RDF query language that’s bringing new possibilities to semantic web, linked data, and big data projects. This updated and expanded edition shows you how to use SPARQL 1.1 with a variety of tools to retrieve, manipulate, and federate data from the public web as well as from private sources.

Author Bob DuCharme has you writing simple queries right away before providing background on how SPARQL fits into RDF technologies. Using short examples that you can run yourself with open source software, you’ll learn how to update, add to, and delete data in RDF datasets.

  • Get the big picture on RDF, linked data, and the semantic web
  • Use SPARQL to find bad data and create new data from existing data
  • Use datatype metadata and functions in your queries
  • Learn techniques and tools to help your queries run more efficiently
  • Use RDF Schemas and OWL ontologies to extend the power of your queries
  • Discover the roles that SPARQL can play in your applications

Publisher resources

View/Submit Errata

Table of contents

  1. Learning SPARQL
  2. Dedication
  3. Preface
    1. Why Learn SPARQL?
    2. Organization of This Book
    3. Conventions Used in This Book
    4. Documentation Conventions
    5. Using Code Examples
    6. Safari® Books Online
    7. How to Contact Us
    8. Acknowledgments
  4. 1. Jumping Right In: Some Data and Some Queries
    1. The Data to Query
    2. Querying the Data
    3. More Realistic Data and Matching on Multiple Triples
    4. Searching for Strings
    5. What Could Go Wrong?
    6. Querying a Public Data Source
    7. Summary
  5. 2. The Semantic Web, RDF, and Linked Data (and SPARQL)
    1. What Exactly Is the “Semantic Web”?
    2. URLs, URIs, IRIs, and Namespaces
    3. The Resource Description Framework (RDF)
      1. Storing RDF in Files
      2. Storing RDF in Databases
      3. Data Typing
      4. Making RDF More Readable with Language Tags and Labels
      5. Blank Nodes and Why They’re Useful
      6. Named Graphs
    4. Reusing and Creating Vocabularies: RDF Schema and OWL
    5. Linked Data
    6. SPARQL’s Past, Present, and Future
    7. The SPARQL Specifications
    8. Summary
  6. 3. SPARQL Queries: A Deeper Dive
    1. More Readable Query Results
      1. Using the Labels Provided by DBpedia
      2. Getting Labels from Schemas and Ontologies
    2. Data That Might Not Be There
    3. Finding Data That Doesn’t Meet Certain Conditions
    4. Searching Further in the Data
    5. Searching with Blank Nodes
    6. Eliminating Redundant Output
    7. Combining Different Search Conditions
    8. FILTERing Data Based on Conditions
    9. Retrieving a Specific Number of Results
    10. Querying Named Graphs
    11. Queries in Your Queries
    12. Combining Values and Assigning Values to Variables
    13. Creating Tables of Values in Your Queries
    14. Sorting, Aggregating, Finding the Biggest and Smallest and...
      1. Sorting Data
      2. Finding the Smallest, the Biggest, the Count, the Average...
      3. Grouping Data and Finding Aggregate Values within Groups
    15. Querying a Remote SPARQL Service
    16. Federated Queries: Searching Multiple Datasets with One Query
    17. Summary
  7. 4. Copying, Creating, and Converting Data (and Finding Bad Data)
    1. Query Forms: SELECT, DESCRIBE, ASK, and CONSTRUCT
    2. Copying Data
    3. Creating New Data
    4. Converting Data
    5. Finding Bad Data
      1. Defining Rules with SPARQL
      2. Generating Data About Broken Rules
      3. Using Existing SPARQL Rules Vocabularies
    6. Asking for a Description of a Resource
    7. Summary
  8. 5. Datatypes and Functions
    1. Datatypes and Queries
      1. Representing Strings
      2. Comparing Values and Doing Arithmetic
    2. Functions
      1. Program Logic Functions
      2. Node Type and Datatype Checking Functions
      3. Node Type Conversion Functions
      4. Datatype Conversion
      5. Checking, Adding, and Removing Spoken Language Tags
      6. String Functions
      7. Numeric Functions
      8. Date and Time Functions
      9. Hash Functions
    3. Extension Functions
    4. Summary
  9. 6. Updating Data with SPARQL
    1. Getting Started with Fuseki
    2. Adding Data to a Dataset
    3. Deleting Data
    4. Changing Existing Data
    5. Named Graphs
      1. Dropping Graphs
      2. Named Graph Syntax Shortcuts: WITH and USING
      3. Copying and Moving Entire Graphs
      4. Deleting and Replacing Triples in Named Graphs
    6. Summary
  10. 7. Query Efficiency and Debugging
    1. Efficiency Inside the WHERE Clause
      1. Reduce the Search Space
      2. OPTIONAL Is Very Optional
      3. Triple Pattern Order Matters
      4. FILTERs: Where and What
      5. Property Paths Can Be Expensive
    2. Efficiency Outside the WHERE Clause
    3. Debugging
      1. Manual Debugging
      2. SPARQL Algebra
      3. Debugging Tools
    4. Summary
  11. 8. Working with SPARQL Query Result Formats
    1. SPARQL Query Results XML Format
      1. Processing XML Query Results
    2. SPARQL Query Results JSON Format
      1. Processing JSON Query Results
    3. SPARQL Query Results CSV and TSV Formats
      1. Using CSV Query Results
      2. TSV Query Results
    4. Summary
  12. 9. RDF Schema, OWL, and Inferencing
    1. What Is Inferencing?
      1. Inferred Triples and Your Query
      2. More than RDFS, Less than Full OWL
    2. SPARQL and RDFS Inferencing
    3. SPARQL and OWL Inferencing
    4. Using SPARQL to Do Your Inferencing
    5. Querying Schemas
    6. Summary
  13. 10. Building Applications with SPARQL
    1. Applications and Triples
      1. Property Functions
      2. Model-Driven Development
    2. SPARQL and Web Application Development
    3. SPARQL Processors
      1. Standalone Processors
      2. Triplestore SPARQL Support
      3. Middleware SPARQL Support
      4. Public Endpoints, Private Endpoints
    4. SPARQL and HTTP
      1. GET a Graph of Triples
      2. PUT a Graph of Triples
      3. POST a Graph of Triples
      4. DELETE a Graph of Triples
    5. Summary
  14. 11. A SPARQL Cookbook
    1. Themes and Variations
    2. Exploring the Data
      1. How Do I Look at All the Data at Once?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      2. What Classes Are Declared?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. What Properties Are Declared?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Which Classes Have Instances?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. What Properties Are Used?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. Which Classes Use a Particular Property?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. How Much Was a Given Property Used?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. How Much Was a Given Class Used?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. A Given Class Has Lots of Instances. What Are These Things?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. What Data Is Stored About a Class’s Instances?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. What Values Does a Given Property Have?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. A Certain Property’s Values Are Resources. What Data Do We Have About Them?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      13. How Do I Find Undeclared Properties?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      14. How Do I Treat a URI as a String?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      15. Which Data or Property Name Includes a Certain Substring?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      16. How Do I Convert a String to a URI?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      17. How Do I Query a Remote Endpoint?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      18. How Do I Retrieve Triples from a Remote Endpoint?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    3. Creating and Updating Data
      1. How Do I Delete All the Data?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      2. How Do I Globally Replace a Property Value?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. How Do I Replace One Property with Another?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. How Do I Change the Datatype of a Certain Property’s Values?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. How Do I Turn Resources into Instances of Declared Classes?
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    4. Summary
  15. Glossary
  16. Index
  17. About the Author
  18. Colophon
  19. Copyright

Product information

  • Title: Learning SPARQL, 2nd Edition
  • Author(s): Bob DuCharme
  • Release date: July 2013
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449371470