Graham Kemp


Computing Science Graduate Course

The Functional Approach to Data Management:
List Comprehensions and Data Integration

24-28 May 2004


Practical 3

Query transformation and optimisation


Web Interfaces


Getting Started with P/FDM

The P/FDM executable is in /users/mdstud/kemp/bin/pfdm
To start P/FDM, just type the name of this file at the UNIX prompt.

To read the schema file for the University database into P/FDM, use the predicate daplex/1, e.g.:

| ?- daplex('/users/mdstud/kemp/pfdm/unidb/unidb.sch').

To load data into P/FDM, use the predicate pfdm_load/1, e.g.

| ?- pfdm_load('/users/mdstud/kemp/pfdm/unidb/unidb.loa').

To compile the file of example Daplex queries, type:

| ?- daplex('unidb.d').

Daplex queries are translated into Prolog for execution. To run one of the programs, type its name (e.g. p1.). You can view the generated Prolog code using listing/1 (e.g. listing(p1).). Examine the code generated for several programs, including p6.

Daplex queries can be typed directly. Use daplex/0 to get the Daplex prompt, e.g.

| ?- daplex.
|: for each t in teacher
|: print(forename(t), surname(t));

Type another semi-colon to return to the Prolog prompt.

If you want to see the intermediate comprehensions, you can turn on/off diagnostic output with the following instructions:

| ?- compiler_debug(on).
| ?- compiler_debug(off).

When you have finished using P/FDM you can exit from the Prolog environment by typing:

| ?- halt.
Further information can be found in the P/FDM User's Manual.

Exercises

  1. The files for the university database are in /users/mdstud/kemp/pfdm/unidb

    Look at the Prolog code generated for queries like p5 and p6. Look at the intermediate comprehensions for these queries.

  2. The files for the antibody database examples are in /users/mdstud/kemp/pfdm/antibody

    The internal form of the rewrite rules can be seen by typing:

    | ?- listing(krr).
    
  3. The files for the "ship example" are in /users/mdstud/kemp/pfdm/ship

    Look at the intermediate comprehensions and see how the query is transformed.


Longer Exercises