Assume I writing an email applicaiton. Now I want to send some messages to specified person, some messages to multiple person, some messages to specified group and some to all members. I am wondering in the best practice I have to treat every mail like a one instance mail, I mean I if I am sending mail to all I have to assign one record for every person or I can define a type field and from the code I must handle with codes.

  • Repeated data is usually a no-no. – Rick James Nov 24 '17 at 19:15
Mail Master table

MailID (PK)
Mail content 

Emp Master table

EmpID (PK)

Mail-Employee Mapping table

Mail-Employee_ID (auto increament id PK)
MailID (FK)
EmployeeID (FK)

Group_Master table

GroupID (auto increament PK)

Group_Employee_Mapping table

Group_Employee_ID (auto increament)
GroupID (FK)
EmployeeID (FK)
(GroupID+Employee are unique so Composite PK)

I think tables and their roles are self explanatory.

Some rule for Group Master:-

Group_Employee_Mapping is predefined in system :you have already mapped all employee and its group in this table.One employee can belong to many group .

If Group='All' don't store "All" employee in Group_Employee_Mapping Table.As this is unnecessary

If user select "All" select all employee from Employee Table ,send them mail and store each employee and mailid in "Mail-Employee Mapping" table

If user select any specific group then select those employee from Group_Employee_Mapping table,send them mail and store them in Mail-Employee Mapping

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.