create db functions