Part-way through writing the database API - nothing works, nothing tested :)