Added associations and corrected database connection