Update db sql script; Implemented more APIs with transaction in mind.