Science With the Virtual Observatory
2006 Summer School

ADQL -- Examples and Exercises

The exercises presented here are companions to the presentation ADQL (PDF, PPT).

In this presentation, we'll look at the tools from the ADQL library that comes with in your summer school software package. If you sat through the Advanced XML Technologies and followed the exercises, then you do not have to rebuild the library. If you missed that session, then building is easy; just change into the adqllib package directory and run ant:

on Linux/MacOS:
cd $NVOSS_HOME/java/src/adqllib
ant
   on Windows:
cd %NVOSS_HOME%\java\src\adqllib
ant

25 seconds or so later, you should see ant print "BUILD SUCCESSFUL" to the screen. If you are Linux or MacOS, you might want to type rehash to ensure the new tools are available to you.

Exercise 1: Sample ADQL Queries

Through the slide talk we're going to look at various ADQL examples on the OpenSkyPortal query interface. In this light exercise, we're going to look at and discuss a few of the examples shown in the right-hand list.

  1. Single Node Join: notice how this query does the inner join between two tables at the same node. These two tables share a common column in specobjid.

  2. XMatch/Region: Here we do a simple cross-match restricted over a region.

  3. XMatch/Region 2: This query incorporates additional constraints into the cross match. In particular, it sets a color constraint formed across the databases.

  4. Three Node Match: This includes a third database, USNO-B, that we don't want the source to appear in.

Exercise 2. Converting between ADQL/s and ADQL/x

We'll now have a look at the adillib tools. If you haven't already, change into the java/src/adqllib directory. There you will see a samples directory. Change into the samples/v0.7.4:

on Linux/MacOS:
cd samples/v0.7.4
   on Windows:
cd samples\v0.7.4
This directory contains a set of sample files containing ADQL/x and ADQL/s queries. You can use the convertADQL tool to convert them to the other format.
  1. To get the flavor of what ADQL/x looks like, open one of the files in this directory. Don't worry if this looks like nonsense to you.

  2. To convert one of our samples to ADQL/s, type the following:

    convertADQL -v v0.7.4 -x adql-circle.xml

    If you wish, you can save the output to a file with the -o option; then you can go the other way with the -s option.

  3. Try converting an ADQL/s query to ADQL/x:

    convertADQL -v v0.7.4 -s adql-simple.sql
    or
    convertADQL -v v0.7.4 -S "SELECT a.* FROM Tab a"

  4. Try composing your own ADQL/s queries and convert them using the above command-line pattern.


The NVO Summer School is made possible through the support of the National Science Foundation and the National Aeronautics and Space Administration.