Cities Database
|
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 Antonio | Texas | 1,500,000 |
DISTANCE | ||
---|---|---|
CITY1 | CITY2 | MILES |
Huston | Bastrop | 130 |
Huston | Huntsville | 60 |
Huntsville | Dallas | 100 |
Austin | Waco | 110 |
Waco | Dallas | 100 |
Dallas | Shreveport | 200 |
Austin | Bastrop | 30 |
Austin | San Antonio | 80 |
San Antonio | Huston | 190 |
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) } ).
lt_city(C, Pop) <- city(C, `Texas`, Pop), Pop > 400000.
query lt_city(C, Pop)
lt_city(`Huston`, 3000000) lt_city(`Dallas`, 2000000) lt_city(`Austin`, 750000) lt_city(`San Antonio`, 1500000)
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.
Then, the user can compile this export, and then run the following query:
The answers are then returned (but if no export match this bound/free pattern an error message is returned)
Example of Query Forms
A constant is a string of symbols beginning with a lowercase letter. Constants are names of objects such as chain_stay, joe. If we want to use constants starting with an uppercase letter, then we must enclose them in quotes, e.g., 'Houston'.
A variable is a string of symbols beginning with an uppercase letter. Examples are Subpart, Price, X123. Variables denote unspecified values that are assigned during the execution of an program.