Saving and fetching the preferences of the user in the database