so I have a table called "Event" and I want to create another table where an Event can contain more Events from the same table. This is what I have so far.
This is the current existing table...
CREATE TABLE [dbo].[EventEvents]
(
[step_id] [uniqueidentifier] NOT NULL PRIMARY KEY,
[title] [nvarchar](200) NOT NULL,
[Enabled] [bit] NOT NULL,
)
Then this is the table I am trying to create...
CREATE TABLE [dbo].[EventEvents]
(
[EventId] [uniqueidentifier] NOT NULL,
[EventChildId] [uniqueidentifier] NOT NULL,
[Enabled] [bit] NOT NULL,
CONSTRAINT [PK_EventEvents] PRIMARY KEY ([EventId], [EventChildId]),
CONSTRAINT [FK_Event_EventChild] FOREIGN KEY ([EventId],[EventChildId]) REFERENCES [dbo].[Event] ([step_id], [step_id])
)
So both EventId and EventChildId both are foreign keys to Event - step_id as 1 event can other events as children within it. But I need both EventId and EventChildId to be composite primary keys. How can I do this?
At the moment I get an error saying:
Duplicate columns specified in FOREIGN KEY constraint key list
Thanks