db restructuring script