Storing history items in the db