in reply to Query database in Prolog
[Added: Prolog SQL has some good info. You should definately avoid re-inventing a wheel. The real Prolog people have already been hacking on this problem.]
I was thinking about this yesterday. It seemed most natural that you'd patch AI::Prolog to be able to query this stuff. You might want to introduce a new built-in function to represent joins. You've got a problem in that SQL relations have no order to columns so you'll either need to ignore that or instruct AI::Prolog in what order to read columns when querying the database.
% A "normal" lookup city('New York', Cityid), usr(Cityid, Name, Id). % An id-less query. Maybe the engine notices the join and transforms t +his into the prior behind the scenes. % Maybe an invented built-in like references/4 cause the transformatio +n. :- references( 'USR', 'CITY_ID', 'USR', 'CITY_ID' ). usr( city( 'New York' ), Name ).
⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Query database in Prolog
by zby (Vicar) on Dec 29, 2005 at 20:16 UTC | |
by diotalevi (Canon) on Dec 29, 2005 at 20:32 UTC | |
by zby (Vicar) on Dec 29, 2005 at 20:52 UTC | |
by tilly (Archbishop) on Dec 29, 2005 at 21:58 UTC | |
by zby (Vicar) on Dec 30, 2005 at 07:56 UTC | |
| |
by diotalevi (Canon) on Dec 29, 2005 at 20:55 UTC |