Reputation: 4548
I am writing a process for sending email notification. Currently I write the email notifications in a table with the following columns:
sender and recipient can be of type User or Group. Obviously at the moment I cannot have FKs for sender or recipient.
1) The first option is to use Any in the mapping and add two additional columns for the type.
2) The second option is to create 4 classes for each combination and map them using discriminator:
class1 => sender of type Group, recipient of type Group
class2 => sender of type Group, recipient of type User
class3 => sender of type User, recipient of type Group
class4 => sender of type User, recipient of type User
3) Other options?
What do you think about this?
Best Regards
Upvotes: 2
Views: 67
Reputation: 6742
you could also create a EmailEntityBase
(or whatever better phrasing you may find) class, from which both Group
and User
will inherit.
then your Notification
entity would refer to EmailEntityBase
sender and recipient properties.
Upvotes: 0
Reputation: 15303
If it were me and I had control over the database I would change the two columns sender_id and recipient_id to sender and recipients. These would be string fields that contain the raw email addresses you are intending to use.
This is just another way to do it. Not necessarily the best as far as database design is concerned but simple from an implementation and mapping perspective.
Upvotes: 1