Table of Contents Next: Database: facts and schema     Cities Database

example1.prg example1.fac

Consider the following two examples:

CITY
NAME STATE POPULATION
Houston Texas 3,000,00
Dallas Texas 2,000.000
Huntsville Texas 150,000
Austin Texas 750,000
Corsicana Texas 60,000
Shreveport Luisiana 90,000
Bastrop Texas 6,000
San AntonioTexas 1,500,000

DISTANCE
CITY1 CITY2 MILES
HustonBastrop130
Huston Huntsville60
Huntsville Dallas 100
AustinWaco 110
Waco Dallas 100
Dallas Shreveport 200
AustinBastrop 30
Austin San Antonio 80
San AntonioHuston 190

Previous: 
Cities Database Table of Contents Next: Rules and Queries    Database: Facts and Schema

Facts

city('Houston', 'Texas', 3000000).
distance('Austin', 'Waco', 110).
assembly(wheel, spoke, 36).

Schema

database( { city(Name:string, State:string, Population:integer),
            distance(City1:string, City2:string, Distance:integer)
          } ).

Previous: Database--facts and schema Table of Contents Next: Queries and Query Forms    Rules and Queries

Derivated predicates and rules The command
 query lt_city(`Austin`, 2000000) 
will actually be used in the regular interface, while in the Java interface the user will select an item from the menu.

Previous: Rules and Queries Table of Contents Next: Constructs    Queries and Query Forms

Query Forms are a.k.a. Exports For instance, if the program file contains:

export lt_city($X, Y)

Then, the user can compile this export, and then run the following query:

query lt_city (`Austin`, Pop )

The answers are then returned (but if no export match this bound/free pattern an error message is returned)

Example of Query Forms

Previous: Queries and query forms Table of Contents Next: More on Rules    Constructs

Basic Language Constructs



Next Page Top of Page
Carlo Zaniolo, 1997