Database Modeling - Either/Or in Many-to-Many
Posted
by
EkoostikMartin
on Stack Overflow
See other posts from Stack Overflow
or by EkoostikMartin
Published on 2012-08-27T21:36:42Z
Indexed on
2012/08/27
21:38 UTC
Read the original article
Hit count: 315
sql
|database-design
I have an either/or type of situation in a many-to-many relationship I'm trying to model.
So I have these tables:
Message
----
*MessageID
MessageText
Employee
----
*EmployeeID
EmployeeName
Team
----
*TeamID
TeamName
MessageTarget
----
MessageID
EmployeeID (nullable)
TeamID (nullable)
So, a Message
can have either a list of Employee
s, or a list of Team
s as a MessageTarget
. Is the MessageTarget
table I have above the best way to implement this relationship? What constraints can I place on the MessageTarget
effectively? How should I create a primary key on MessageTarget
table?
© Stack Overflow or respective owner