database: factorize insert and replace