What if your iDevice and your Mac computer had their Contacts or Messages synced? Delete on one and it deletes on the other. Restore the database on one (the Mac) and it restores on the other?
The way synching works for Contacts is complicated by the fact that the time actions take place is considered as part of the synching. Recovering a contact might be possible as you propose but it would be a several step process on multiple devices including syncing and un-syncing at least one of the devices two or three times.
Messages, on the other hand, ARE NOT SYNCHED between devices. Each device receives the messages independently and they have to be deleted on each device.
IMAP Email is not synchronized in the traditional sense either. Accounts and account setups are synced via iCloud, but the Email itself is a mirror of the account on the provider's IMAP server. So to recover deleted eMail generally requires the services of the Internet Service Provider and their backup utilities.