It is important to note that a contact is associated with the logged-in user and the user cannot access contacts that do not belong to her. The user cannot have multiple contacts with the same email address; an email address is unique in relation to a user. However, the user can have multiple Contact Lists, and a contact can appear in multiple lists. The diagram in Figure 8-1 clarifies the relationships between user, contact, and Contact List.
Figure 8-1. Figure 8-1
Figure 8-1 illustrates that:
A user can have multiple Contact Lists.
A user can have multiple contacts with unique emails.
A Contact List can have multiple contacts with unique emails.
So, what exactly is a contact? At the most basic level, a contact is simply an email address, but most likely we want to gather more information about a contact than just an email address. For now, we will say that the contact entity has these properties:
Date of birth
The email address is the only required value.
8.2.1. Create a Contact
A contact can be created manually by filling out a form or can be imported from a file. We focus on manual creation for now. When adding a contact, we want to ensure that it doesn't already exist, and if it does, we should display an error to the user. We will also notify the user upon a successful creation. To improve usability, we will also give the user the option to ...