Moved database access parts from data views into separate functions in data module.