0
votes

I have a conference table. A conference can have a list of associated conferences. Is this what is refereed to as a recursive associations?

And Is this accomplished by having another table ConferenceAssociatedConference with two fields (ConferenceId, AssociatedConferenceId) and these two fields are both foreign keys pointing on the same ConferenceId field of the Conference Table?

I though the above was correct but when creating and building my edmx I get:

Error 6 Error 3034: Problem in mapping fragments starting at lines 875, 982:Two entities with possibly different keys are mapped to the same row. Ensure these two mapping fragments map both ends of the AssociationSet to the corresponding columns.

CREATE TABLE [dbo].[ConferenceAssociatedConference](
    [ConferenceId] [nvarchar](50) NOT NULL,
    [AssociatedConferenceId] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_ConferenceAssociatedConference] PRIMARY KEY CLUSTERED 
(
    [ConferenceId] ASC,
    [AssociatedConferenceId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[ConferenceAssociatedConference]  WITH CHECK ADD      CONSTRAINT [FkConfAssociatedConf_AssociatedConferenceId] FOREIGN     KEY([AssociatedConferenceId])
REFERENCES [dbo].[Conference] ([ConferenceId])
GO

ALTER TABLE [dbo].[ConferenceAssociatedConference] CHECK CONSTRAINT     [FkConfAssociatedConf_AssociatedConferenceId]
GO

ALTER TABLE [dbo].[ConferenceAssociatedConference]  WITH CHECK ADD      CONSTRAINT [FkConfAssociatedConf_ConferenceId] FOREIGN KEY([ConferenceId])
REFERENCES [dbo].[Conference] ([ConferenceId])
GO

ALTER TABLE [dbo].[ConferenceAssociatedConference] CHECK CONSTRAINT  [FkConfAssociatedConf_ConferenceId]
GO
2

2 Answers

0
votes

Yes, what you describe is correct. What does your DML look like?

0
votes

The easiest way I've seen to do this is with a parent/child concept. Add a 'ParentConference' column to your conference table and default it to null. Conferences can be associated by populating the new column with the ID of the main conference. This is a common practice for things like tradeshows, which usually have an associated professional conference or seminar series. The limitation is that it requires one record of any given group to be the parent of the group, which may not fit your needs.

If you don't want to do that, I'd suggest making a ConferenceType table and categorizing your conferences that way. It's easy and much less messy than mucking around with many-to-many flow.