Implemented db access for goals