An unhealthy childhood could affect the brain in later life, potentially leading to a greater risk of dementia, an Oxford University study has found.