Database saving and updating record counts