RIDIQL Reference
RIDIQL (RDF Insertion Deletion Inspection and Query Language)
builds several utility commands on top of RDQL to make working with RDF graphs
easy. This reference describes each of the commands and gives examples where appropriate.
Note: All commands may be written on multiple lines and are terminated with
a ; character. Command names and tokens are case-insensitive, but when
written in this reference, they are capitalized for clarity.
Command Index
Connecting
ATTACH - Connects to a given file or db store.
Syntax:
- To attach a filesystem store:
ATTACH storeName path; - To attach a database store:
ATTACH storeName dbType url driverClass user pass;
Where:
- storeName is the name you'll use to refer to the newly attached store.
- path is the relative or absolute directory path containing the models (files) of the filesystem store.
- dbType is either McKoi, MySQL, Oracle, or PostgreSQL.
- url is the JDBC url of the database to use.
- driverClass is the classname of the JDBC driver to use.
- user is the username with which to connect to the database.
- pass is the password of the database user.
Examples:
- Attaching a filesystem store at the current directory
ATTACH mystore .; - Attaching a filesystem store at /mystore
ATTACH mystore /mystore; - Attaching a McKoi database store
ATTACH mystore McKoi jdbc:mckoi://localhost:9167/ com.mckoi.JDBCDriver rdqlplus rdqlplus; - Attaching a MySQL database store
ATTACH mystore MySQL jdbc:mysql://localhost/test com.mysql.jdbc.Driver myname mypass; - Attaching an Oracle database store
ATTACH mystore Oracle jdbc:oracle:thin:@localhost:1521:mysid oracle.jdbc.driver.OracleDriver myname mypass; - Attaching a Postgresql database store
ATTACH mystore PostgreSQL jdbc:postgresql://localhost/test org.postgresql.Driver myname mypass;
A store must be attached (and thus named) before you can USE its
models. RDQLPlus remembers the name and location details of an
attached store until it is DETACHed . . . you won't
need to re-attach each time you use the program.
RDQLPlus comes with an embedded instance of the Mckoi database, which
is already attached the first time you run the program. You don't
need to worry about setting this up. But to use another
database type, you must first download the appropriate JDBC driver.
Find pointers at the Jena MySQL HOWTO,
Oracle HOWTO, or
Postgresql HOWTO page.
Once you obtain the correct driver, make sure its java classes are unpacked
into the RDQLPLUS_HOME/ext directory so RDQLPlus can use them.
Note that in order to use Oracle, as the HOWTO indicates, you
will need to modify Jena source code. If you choose this route, make sure
to swap out the RDQLPLUS_HOME/lib/jena.jar file with your own (Jena v2.1) before
attempting to use Oracle with RDQLPlus.
DETACH - Disconnects from/forgets about a named store.
Syntax:
- DETACH storeName;
Where:
- storeName is the name of the store to detach.
Note: You can't
detach a store whose model is in use, and the memory store can never be
detached.
MODELS - Lists all models in each attached store.
Syntax:
- MODELS;
Every model in each attached store will be listed.
USE - Sets the current model.
Syntax:
- USE modelName@storeName;
Where:
- modelName is the name of the model to switch to.
- storeName is the name of the store where it exists.
If there is an open transaction
on the current model, it will be automatically ABORTed
before switching.
Creating, Modifying, and Exporting
CREATE - Creates a model in a store.
Syntax:
- CREATE modelName@storeName;
Where:
- modelName is the name of the model to create.
- storeName is the name of the store in which to create it.
CREATEINF - Creates an inference model.
Syntax:
- CREATEINF modelName type ontModel@store sourceModel@store;
Where:
- modelName is the name of the inference model to create.
- type is one of the following inference types.
- DAML_RDFS - for DAML models using the RDFS Reasoner.
- DAML_RULE - for DAML models using the DAMLMicroReasoner.
- DAML_TRANS - for DAML models using the Transitive Reasoner.
- OWL_DL_RDFS - for OWL DL models using the RDFS Reasoner.
- OWL_DL_RULE - for OWL DL models using the OWL Reasoner.
- OWL_DL_TRANS - for OWL DL models using the Transitive Reasoner.
- OWL_LITE_RDFS - for OWL LITE models using the RDFS Reasoner.
- OWL_LITE_RULE - for OWL LITE models using the OWL Reasoner.
- OWL_LITE_TRANS - for OWL LITE models using the Transitive Reasoner.
- OWL_RDFS - for OWL FULL models using the RDFS Reasoner.
- OWL_RULE - for OWL FULL models using the OWL Reasoner.
- OWL_TRANS - for OWL FULL models using the Transitive Reasoner.
- RDFS_RDFS - for RDFS models using the RDFS Reasoner.
- RDFS_TRANS - for RDFS models using the Transitive Reasoner.
- ontModel@store specifies the model and store of the ontology to draw inferences from.
- sourceModel@store specifies the model and store of the source over which the ontology should be applied.
Examples:
- Creating an inference model using the transitive reasoner with RDFS
CREATEINF myinf RDFS_TRANS myschema.rdfs@mystore mystatements@mystore; - Creating an inference model using the OWL reasoner with OWL_FULL
CREATEINF myinf OWL_RULE myschema.owl@mystore mystatements@mystore;
Although the ontology and source models can be from a persistent store,
there is no support for persistent inference models -- they will always
be created in memory. Thus, after creation, an inference model can be
found at modelName@memory.
If the source data is modified, the inference model won't
reflect the new entailments until you issue the REBIND command.
Note that an inference model can be created in which the ontology statements
are already in the same model as the source statements. To do this,
you can create an empty model and pass THAT in as the ontology model...
passing the empty model in as the source model.
DELETE - Removes statement(s) from the model.
Syntax:
- To delete specific statements:
DELETE statementList; - To delete statements involved in a query:
DELETE selectStatement;
Where:
- statementList is a series of statements to delete, each of one of the following forms:
- <subjURI> <predURI> <objURI>
- <subjURI> <predURI> 'literal'
- <subjURI> <predURI> 'literal'@langCode
- <subjURI> <predURI> 'literal'^^datatypeURI
- <subjURI> <predURI> 'literal'^^<datatypeURI>
- selectStatement follows the syntax of SELECT, specifying that all statements involved in a query should be deleted from the model.
Examples:
- Deleting a statement with a resource as its object:
DELETE <myns:subj> <myns:pred> <myns:obj>; - Deleting a statement with a plain literal as its object:
DELETE <myns:subj> <myns:pred> 'hi'; - Deleting a statement with a literal with a language as its object:
DELETE <myns:subj> <myns:pred> 'hi'@en-US; - Deleting a statement with a literal with a datatype as its object (form 1):
DELETE <myns:subj> <myns:pred> '10'^^xsd:integer; - Deleting a statement with a literal with a datatype as its object (form 2):
DELETE <myns:subj> <myns:pred> '20'^^<xsd:integer>; - Deleting all above statements with one command:
DELETE <myns:subj> <myns:pred> <myns:obj>
<myns:subj> <myns:pred> 'hi'
<myns:subj> <myns:pred> 'hi'@en-US
<myns:subj> <myns:pred> '10'^^xsd:integer
<myns:subj> <myns:pred> '20'^^<xsd:integer>; - Deleting all statements with a certain subject and predicate:
DELETE SELECT * WHERE (<myns:subj> <myns:pred> ?n);
When using DELETE SELECT . . ., you may wish to preview the statements
that will be deleted first by using DRAW SELECT . . .
DUMP - Exports the model in one of three formats.
Syntax:
- To dump the graph to the console window:
DUMP format; - To dump the graph to a file:
DUMP format filename;
Where:
- format is either X, N, or 3, specifying that the graph should be dumped in RDF/XML, N-TRIPLES, or NOTATION-3 format, respectively.
- filename is a (relative or absolute) filename to dump the graph to.
DROP - Permanently removes a model.
Syntax:
- DROP modelName@storeName;
Where:
- modelName@storeName specifies the model to drop.
This command actually does two things. First, it removes all the
statements from a model (equivalent to "DELETE SELECT * (?r ?p ?v);").
Then it removes the actual empty model from the store.
Note that since the
default@memory model cannot be un-associated, DROP will only remove all
statements from it. Also, if you DROP the current in-use model, the
current model will be set to default@memory when the command completes.
LOAD - Imports statements from a file into the model.
Syntax:
- LOAD format filename;
Where:
- format is either X, N, or 3, specifying that the graph is in RDF/XML, N-TRIPLES, or NOTATION-3 format, respectively.
- filename is the (relative or absolute) filename of the file to load.
INSERT - Adds or copies statements to the model.
Syntax:
- To insert specific statements:
INSERT statementList; - To copy ALL statements from another model:
INSERT FROM modelName@storeName; - To copy SOME statements from another model:
INSERT FROM modelName@storeName selectStatement;
Where:
- statementList is a series of statements to add, each of one of the following forms:
- <subjURI> <predURI> <objURI>
- <subjURI> <predURI> 'literal'
- <subjURI> <predURI> 'literal'@langCode
- <subjURI> <predURI> 'literal'^^datatypeURI
- <subjURI> <predURI> 'literal'^^<datatypeURI>
- modelName@storeName is the model to copy statements from.
- selectStatement follows the syntax of SELECT, specifying that all statements involved in a query on modelName@storeName should be inserted into the current model.
Examples:
- Inserting a statement with a resource as its object:
INSERT <myns:subj> <myns:pred> <myns:obj>; - Inserting a statement with a plain literal as its object:
INSERT <myns:subj> <myns:pred> 'hi'; - Inserting a statement with a literal with a language as its object:
INSERT <myns:subj> <myns:pred> 'hi'@en-US; - Inserting a statement with a literal with a datatype as its object (form 1):
INSERT <myns:subj> <myns:pred> '10'^^xsd:integer; - Inserting a statement with a literal with a datatype as its object (form 2):
INSERT <myns:subj> <myns:pred> '20'^^<xsd:integer>; - Inserting all above statements with one command:
INSERT <myns:subj> <myns:pred> <myns:obj>
<myns:subj> <myns:pred> 'hi'
<myns:subj> <myns:pred> 'hi'@en-US
<myns:subj> <myns:pred> '10'^^xsd:integer
<myns:subj> <myns:pred> '20'^^<xsd:integer>; - Inserting a chain of statements involving two bNodes (aka anonymous nodes):
INSERT <myns:subj> <myns:pred2> ?varOne
?varOne <myns:pred2> ?varTwo
?varTwo <myns:pred3> <myns:obj>; - Inserting all statements from another model:
INSERT FROM otherModel; - Inserting some statements from another model:
INSERT FROM otherModel@otherStore SELECT * WHERE (<myns:subj> <myns:pred> ?n);
RANDOM - Creates random statements in the model.
Syntax:
- RANDOM numStatements numResources numPredicates;
Where:
- numStatements is the number of statements to create.
- numResources is the number of distinct resources to randomly involve in statements.
- numPredicates is the number of distinct predicates to involve in statements.
Examples:
- Create 10 statements involving 4 resources with a vocabulary of 2 predicates:
RANDOM 10 4 2; - Create 500 statements involving 200 resources with a vocabulary of 20 predicates:
RANDOM 500 200 20;
This is intended for testing. Resource URIs will start with res:aa and end with a number between
1 and numResources.
Predicate URIs will start with prop:aa and end with a number between 1 and numPredicates.
REBIND - Syncs the inference model with underlying data changes.
Syntax:
- REBIND;
You should only run this command when the current model is
an inference model and the source data has changed since it was
created or the last time it was re-bound.
Files and Directories
Unix-style paths (using /'s) can be used whether you're running
on windows or unix. When specifying paths, .. means "parent directory"
and . means "current directory". Also, if you use paths with space characters
in them, don't use quotes around the path.
CAT - Echoes the content of a text file to the console.
Syntax:
- CAT filename;
Where:
- filename is the (relative or absolute) filename of the text file to echo.
This just provides a quick way to check on the content of a small text file.
Don't run it on large or binary files; you may run out of memory because
the scrollback buffer is currently never cleared.
CD - Changes the working directory.
Syntax:
- To change to the RDQLPLUS_HOME/start (aka ~) directory:
CD; - To change to any directory:
CD path;
Where:
- path is the (relative or absolute) path to the directory to switch to.
The new working directory will be shown in the titlebar of the
console window.
LS - Lists the contents of a directory..
Syntax:
- To list the contents of the working directory:
LS; - To list the contents of any directory:
LS path;
Where:
- path is the (relative or absolute) path of the directory to list.
PWD - Echoes the current working directory.
Syntax:
- PWD;
Note that since the current working directory is always shown in the
titlebar of the console window, this command is really only useful
for running RDQLPlus in non-GUI mode (which doesn't exist at this time).
Querying and Drawing
COUNT - Gives subject, statement, and result binding counts.
Syntax:
- To count subjects, statements, and reified statements in the model:
COUNT; - To count result bindings (rows) and involved subjects and statements in a query:
COUNT selectStatement;
Where:
- selectStatement follows the syntax of SELECT.
When COUNTing on an inference model, the actual number of statements will
be returned (not a lower bound).
SELECT - Performs a RDQL query.
Syntax:
- SELECT variableList [ FROM <modelURI> ] WHERE patternList [ AND boolean [ AND boolean [...] ] [ USING usings ]
Where:
- variableList is a list of one or more variables of the form ?varName, or "*". This specifies the list of variable (from the patternList) binding values that the result should contain. If "*" is specified, all variables' value bindings from the patternList will be returned.
- modelURI is the full URL the rdf to query. If unspecified (the normal case), the currently in-use model will be queried. Using the optional FROM clause does not make sense when the SELECT statement occurs as part of another RIDIQL command.
- patternList consists of one or more patterns to match. These are triples of the form (subject predicate object). Subject, predicate, and object can be specific values (<uri>s or literals) or ?variables. The RDQL tutorial (linked below) gives a more complete picture of how these patterns are written and evaluated.
- boolean is a boolean expression to match. These can use ?variables and literal values with the >, >=, <, <=, ==, EQ, NE, !~, and =~ operators (and more -- see below).
- usings is a list of expressions of the form "abbrev for uriPrefix". When specified, a USING clause's abbrev-to-uriPrefix mapping overrides that of the ALIASes.
This is by no means a definitive description of RDQL syntax. A more
precise and accurate description of RDQL can be found at the
RDQL W3C Submission.
A nice introduction and tutorial to RDQL can be found at
the Jena RDQL Tutorial.
In general, RDQL in RDQLPlus matches the Jena implementation (in fact, it
just passes calls straight to Jena). The only exceptions are those mentioned
above in regard to the FROM clause and the use of ALIASes.
DRAW - Graphically displays a model or query results.
Syntax:
- To draw the entire current model:
DRAW; - To draw statements involved in a query:
DRAW selectStatement
Where:
- selectStatement matches the SELECT syntax.
Note: RDQLPlus uses the GraphViz "dot"
program to do graph layout.
In many cases this only takes up to a few seconds, but sometimes
(if the graph being drawn is VERY large), the program can run for several
minutes, locking up RDQLPlus until it's finished.
Settings and Miscellaneous
ALIAS - Sets, shows, or clears URI aliases.
Syntax:
- To list all aliases:
ALIAS; - To echo the value of an alias:
ALIAS aliasName; - To set the value of an alias:
ALIAS aliasName uriPrefix; - To un-set an alias:
ALIAS aliasName !; - To un-set all aliases:
ALIAS !;
Where:
- aliasName is the name of the alias to echo, set, or un-set.
- uriPrefix is the value of the alias. It must be a syntactically-valid URI.
Example:
- Setting an alias:
ALIAS prop http://www.example.com/properties/#;
After issuing this command, anywhere you would enter:
<http://www.example.com/properties/#myprop>, you can enter
<prop:myprop> instead.
Aliases are used as a convenience in RDQLPlus. You can do everything
without aliases that you could do with them. Any time a command
calls for a URI, you can use aliasName:restOfURI instead of
typing the full URI.
Aliases are also used to aid in readability while DRAWing.
If an alias exists for a URI prefix used in the graph, aliasName:restOfURI
will be shown in the graph instead of the full URI. Note that aliases are
NOT used when printing the results of a plain SELECT command --
full URIs are always printed in the text output of a RDQL query.
Aliases are remembered on subsequent runs of RDQLPlus, until un-set.
EXIT - Exits RDQLPlus.
Syntax:
- EXIT;
If there is an open transaction, it will be ABORTed.
HELP - Provides a brief synopsis of all commands.
Syntax:
- HELP;
TRACE - Turns error tracing or or off.
Syntax:
- To toggle tracing:
TRACE; - To turn tracing on:
TRACE ON; - To turn tracing on:
TRACE OFF;
When tracing is on, error messages will be accompanied by
additional debugging information.
Transactions
Transactions are only possible on filesystem models and on database models
where the underlying RDBMS supports transactions.
For efficiency, filesystem-based models are ALWAYS in a transaction
so changes are only really made when the models are COMMITted.
All other models start in auto-commit mode and you must explicitly issue a BEGIN
command to start a transaction.
Note that the DROP command is always permanent, whether there is a transaction
or not. Thus, DROPs can't be rolled back.
ABORT - Cancels/rolls back the current transaction.
Syntax:
- ABORT;
BEGIN - Starts a transaction on the current model.
Syntax:
- BEGIN;
COMMIT - Commits the current transaction.
Syntax:
- COMMIT;