A new study has concluded that exercise is only able to prevent dementia if the person gets enough sleep.