adds uniqueness validations and db index, completes section 6.2.5