Continued writing the sql layer, for manager and instance