I have a database that has three tables
Messages - PK = MessageId
Drafts - PK = DraftId
History - FK = RelatedItemId
The History table has one foreign key [RelatedItemId] , which maps to one of the two main keys in Messages and Drafts .
Is there a name for this relationship?
Is this just a bad design?
Is there a better way to develop this relationship?
Here are the CREATE TABLE suggestions for this question:
CREATE TABLE [dbo].[History]( [HistoryId] [uniqueidentifier] NOT NULL, [RelatedItemId] [uniqueidentifier] NULL, CONSTRAINT [PK_History] PRIMARY KEY CLUSTERED ( [HistoryId] ASC ) ) CREATE TABLE [dbo].[Messages]( [MessageId] [uniqueidentifier] NOT NULL, CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED ( [MessageId] ASC ) ) CREATE TABLE [dbo].[Drafts]( [DraftId] [uniqueidentifier] NOT NULL, CONSTRAINT [PK_Drafts] PRIMARY KEY CLUSTERED ( [DraftId] ASC ) )
source share