Scientists have found that an unhappy family life could increase a person's risk of developing dementia.