Refine database structure