create db query method.