see also the postgres and sqlite implementations