-Replaced the "sample" code with actual calls into the database code. This
would be very close to finished code, except that it suffers from a bug
that has so far proved intractable to Sam and myself. An email will be
forthcoming detailing the bug. Quite likely, the bug is not specifically
in this file, and in the best case this file won't need to be changed much
for a long time, unless I decide to change the interface for style reasons.