New database interface and queries for getting previous event

Added an interface to the database to get the previous event.  This is
the event, of a specific type, that occurred immediately before the
latest one.  The queries are implemented as part of the various objects
since the values are stored in different tables.