Kyle Edmund achieved one of the biggest wins of his career by defeating Novak Djokovic in the second round of the Madrid Open.