refactored database to expose session and transaction api