Db rewrite