database: refactor parsing/checking