Update the survey view and move some database access code around.