ONTOLOGY ENGINEERING Lab #6 – October 6, 2014. The FILTER Keyword  Up to this point we’ve restricted the result set of a query by binding a variable.

Slides:



Advertisements
Similar presentations
Ontology Engineering Lab #8 October 21, Review - Trial Query Exercises  What are the bones of the foot? (not sure this can be done in a single.
Advertisements

© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 10 – Designing.
Unit 2 Marketing Math.
5 Copyright © 2007, Oracle. All rights reserved. Reporting Aggregated Data Using the Group Functions.
4 การใช้ SQL Functions. Copyright © 2007, Oracle. All rights reserved What Are Group Functions? Group functions operate on sets of rows to give.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 7: Aggregates.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 7: Aggregates.
Structured Query Language Part I Chapter Three CIS 218.
WRITING BASIC SQL SELECT STATEMENTS Lecture 7 1. Outlines  SQL SELECT statement  Capabilities of SELECT statements  Basic SELECT statement  Selecting.
SQL Operations Aggregate Functions Having Clause Database Access Layer A2 Teacher Up skilling LECTURE 5.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® Access 2010 © 2011 The McGraw-Hill Companies,
Chapter 3A Semantic Web Primer 1 Chapter 3 Querying the Semantic Web Grigoris Antoniou Paul Groth Frank van Harmelen Rinke Hoekstra.
Spreadsheets Objective 6.02
2 Explain advanced spreadsheet concepts and functions Advanced Calculations 1 Sabbir Saleh_Lecture_17_Computer Application_BBA.
Xin  Syntax ◦ SELECT field1 AS title1, field2 AS title2,... ◦ FROM table1, table2 ◦ WHERE conditions  Make a query that returns all records.
Chapter 3 Querying RDF stores with SPARQL. Why an RDF Query Language? Why not use an XML query language? XML at a lower level of abstraction than RDF.
SCIENTIFIC NOTATION What is it? And How it works?.
R7 Rational Expressions. Rational Expressions An expression that can be written in the form P/Q, where P and Q are polynomials and Q is not equal to zero.
Using Special Operators (LIKE and IN)
Structured Query Language. Group Functions What are group functions ? Group Functions Group functions operate on sets of rows to give one result per group.
Master Informatique 1 Semantic Technologies Part 7SPARQL 1.1 Werner Nutt.
Information Resource Engineering SQL4. Recap - Ordering Output  Usually, the order of rows returned in a query result is undefined.  The ORDER BY clause.
Intro to SQL Management Studio. Please Be Sure!! Make sure that your access is read only. If it isn’t, you have the potential to change data within your.
Upper and lower bounds starter 28 has been rounded to the nearest whole number. What is the minimum and maximum value?
STARTER Factorise the following: x2 + 12x + 32 x2 – 6x – 16
1.6 Solving Compound and Absolute Value Inequalities.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Overview Excel is a spreadsheet, a grid made from columns and rows. It is a software program that can make number manipulation easy and somewhat painless.
Measurement Sub. :- Mathematics Std. :- 5 th Chapter no. 16.
Fractions Re-cap2 Mathematics. Which is bigger or ? To compare two fractions convert them to fractions with the same denominator. First we need.
© Jalal Kawash Database Queries Peeking into Computer Science.
Fun with Fractions. Important…. It is important that you are able to make calculations with fractions. You must be able to add, subtract, multiply, and.
IFS180 Intro. to Data Management Chapter 13 – Grouping Data.
PeopleSoft Financials Advanced Query Training Financial Information Systems and Reporting Controller’s Division
Structured Query Language SQL-II IST 210 Organization of Data IST2101.
7 th Grade Math Vocabulary Word, Definition, Model Emery Unit 2.
Spreadsheet Calculations Formulas & Functions Computer Applications I.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Subqueries CIS 4301 Lecture Notes Lecture /23/2006.
1.5 Translating Words into Mathematical Symbols
More SQL: Complex Queries,
Lab 13 Databases and SQL.
Scientific Notation.
Group Functions Lab 6.
Lab Skills and Chemical Analysis
Writing Basic SQL SELECT Statements
Oracle Analytic Views Enhance BI Applications and Simplify Development
CS 405G: Introduction to Database Systems
Notes Over 10.1 Polynomial Vocabulary Degree is 1 Degree is 4
SQL – Entire Select.
Chapter 4 Summary Query.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Lecture Notes 8/24/04 (part 2)
EQ: How do I solve an equation in one variable?
Access: SQL Participation Project
23 ×
Introduction to Programming
7th Grade Math Vocabulary
Structured Query Language – The Fundamentals
Spreadsheets 2 Explain advanced spreadsheet concepts and functions
Reporting Aggregated Data Using the Group Functions
Query Functions.
Spreadsheets Objective 6.02
Hundred Dollar Questions
Reporting Aggregated Data Using the Group Functions
Reporting Aggregated Data Using the Group Functions
Spreadsheets Objective 6.02
Objective: Learn to use a table to find equivalent ratios and rates.
Group Operations Part IV.
Presentation transcript:

ONTOLOGY ENGINEERING Lab #6 – October 6, 2014

The FILTER Keyword  Up to this point we’ve restricted the result set of a query by binding a variable to a resource using some object property. For example, the second statement of the following where clause “filters” the result set to roadways in Niagara County: SELECT ?route WHERE { ?route rdf:type dbpedia-owl:RouteOfTransportation. ?route dbpprop:counties. } LIMIT 100

The FILTER Keyword  The FILTER keyword enables filtering on string and numeric values. The following SELECT query returns roadways that have “bridge” somewhere in the english label. SELECT ?route ?label WHERE { ?route rdf:type dbpedia-owl:RouteOfTransportation. ?route rdfs:label ?label. FILTER regex(?label, "bridge", "i"). FILTER (lang(?label)= "en"). } LIMIT 100

The FILTER Keyword  The following SELECT query returns roadways that have lengths greater than 1000 miles. SELECT ?route ?length WHERE { ?route rdf:type dbpedia-owl:RouteOfTransportation. ?route dbpprop:lengthMi ?length. FILTER (?length > 1000) } LIMIT 100

The FILTER Keyword  The following SELECT query returns public universities located in latitudes between 42 and 43 degrees and in longitudes between -79 and -77 degrees. SELECT ?route ?latitude ?longitude WHERE { ?route rdf:type dbpedia-owl:RouteOfTransportation. ?route geo:lat ?latitude. ?route geo:long ?longitude. FILTER (?latitude > 42 && ?latitude < 43). FILTER (?longitude > -79 && ?longitude < -77). } LIMIT 100

The FILTER Keyword  The following SELECT query returns public companies that have revenues of more than 1 billion (US dollars) or equity of more than 100 billion (US dollars) SELECT ?company ?int_revenue ?int_equity WHERE { ?company dbpedia-owl:type dbpedia:Public_company. ?company dbpedia-owl:revenue ?revenue. ?company dbpedia-owl:equity ?equity. FILTER (datatype(?revenue) = ). BIND(xsd:integer(?revenue) as ?int_revenue). BIND(xsd:integer(?equity) as ?int_equity). FILTER (?int_revenue > || ?int_equity > ) } LIMIT 100

The Filter Keyword  The following SELECT query uses the FILTER keyword, logical operator ! and the bound function to return roadways that do not have an associated name of their county SELECT ?route ?county WHERE { ?route rdf:type dbpedia-owl:RouteOfTransportation. OPTIONAL {?route dbpprop:counties ?county }. FILTER(!bound(?county)). } LIMIT 100

The UNION Keyword  Allows you to join multiple queries and return all of the result sets  The following query returns roadways located in Niagara or Orleans counties: SELECT ?route WHERE { { ?route rdf:type dbpedia-owl:RouteOfTransportation. ?route dbpprop:counties. } UNION { ?route rdf:type dbpedia-owl:RouteOfTransportation. ?route dbpprop:counties. } 8

The UNION Keyword  The part of a union query that is common can be written just once: SELECT ?route WHERE { ?route rdf:type dbpedia-owl:RouteOfTransportation. {?route dbpprop:counties.} UNION {?route dbpprop:counties.} } 9

GROUP BY Keyword  Allows grouping of data together into sets on which aggregate functions can be performed  The following query returns the total length roadways by US state: SELECT ?state (SUM(?length) AS ?totalroadways) WHERE { ?route rdf:type dbpedia-owl:RouteOfTransportation. ?route dbpprop:counties ?county. ?county dbpedia-owl:state ?state. ?route dbpprop:lengthMi ?length. } GROUP BY ?state ORDER BY DESC(?totalroadways) 10

GROUP BY Keyword  Other functions available for use include AVG(), MIN(), MAX(), and COUNT()  The following query returns the average length of roadways by US state: SELECT ?state (AVG(?length) AS ?avgroadways) WHERE { ?route rdf:type dbpedia-owl:RouteOfTransportation. ?route dbpprop:counties ?county. ?county dbpedia-owl:state ?state. ?route dbpprop:lengthMi ?length. } GROUP BY ?state ORDER BY DESC(?avgroadways) 11

HAVING Keyword  Works for aggregate values in the same way as the FILTER keyword works for individual values  The following query returns states having more than 70,000 miles in roadways: SELECT ?state (SUM(?length) AS ?totalroadways) WHERE { ?route rdf:type dbpedia-owl:RouteOfTransportation. ?route dbpprop:counties ?county. ?county dbpedia-owl:state ?state. ?route dbpprop:lengthMi ?length. } GROUP BY ?state HAVING (SUM(?length) > 70000) ORDER BY DESC(?totalroadways) 12

Mathematical Functions  Allow individual values to be added, subtracted, multiplied and divided to return calculated values  The following query returns the area per mile ratio for states in the United States SELECT ?state (?area /(SUM(?length) as ?totallength) as ?areapermile) WHERE { ?route rdf:type dbpedia-owl:RouteOfTransportation. ?route dbpprop:counties ?county. ?county dbpedia-owl:state ?state. ?route dbpprop:lengthMi ?length. ?state dbpedia-owl:areaTotal ?area. } ORDER BY DESC(?areapermile) 13

Building a Top Ten List of Area to Length Ratios SELECT ?state (?area /(SUM(?length) as ?totallength) as ?areapermile) WHERE { ?route rdf:type dbpedia-owl:RouteOfTransportation. ?route dbpprop:counties ?county. ?county dbpedia-owl:state ?state. ?route dbpprop:lengthMi ?length. ?state dbpedia-owl:areaTotal ?area. } ORDER BY DESC(?areapermile) LIMIT 10 14

Exercises  Find the number of roadways in counties of New York State  Find the roadways that have a mention of “Buffalo” somewhere in the english version of their abstract  Find roadways that are located in (dbpedia- owl:location) either Toronto or Edmonton  Find roadways that are located in counties that have a population (dbpedia-owl:populationTotal) greater than 1.5 million