I am writing a data access library using the ADO Entity Framework in Visual Studio 2008 SP1 using the .NET Framework 3.5 SP1. I am trying to create associat
This is quite an undesirable solution because it explodes out the number of columns you need.
For the Link/Node example above, the resulting database schema would look like this:
SQL:
USE [GraphExample2]
GO
/****** Object: Table [dbo].[Node] Script Date: 02/26/2009 15:45:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Node](
[NodeID] [int] IDENTITY(1,1) NOT NULL,
[NodeTypeDiscriminator] [int] NOT NULL,
[Name] [varchar](255) NOT NULL,
[Description] [varchar](1023) NULL,
CONSTRAINT [PK_Node] PRIMARY KEY CLUSTERED
(
[NodeID] 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
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Link] Script Date: 02/26/2009 15:45:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Link](
[LinkID] [int] IDENTITY(1,1) NOT NULL,
[LinkTypeDiscriminator] [int] NOT NULL,
[LeaderID] [int] NULL,
[FollowerID] [int] NULL,
[PersonID] [int] NULL,
[LocationID] [int] NULL,
[Name] [varchar](255) NULL,
[Description] [varchar](1023) NULL,
CONSTRAINT [PK_Link] PRIMARY KEY CLUSTERED
(
[LinkID] 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
SET ANSI_PADDING OFF
GO
/****** Object: ForeignKey [FK_Link_Node_Follower] Script Date: 02/26/2009 15:45:53 ******/
ALTER TABLE [dbo].[Link] WITH CHECK ADD CONSTRAINT [FK_Link_Node_Follower] FOREIGN KEY([FollowerID])
REFERENCES [dbo].[Node] ([NodeID])
GO
ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Follower]
GO
/****** Object: ForeignKey [FK_Link_Node_Leader] Script Date: 02/26/2009 15:45:53 ******/
ALTER TABLE [dbo].[Link] WITH CHECK ADD CONSTRAINT [FK_Link_Node_Leader] FOREIGN KEY([LeaderID])
REFERENCES [dbo].[Node] ([NodeID])
GO
ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Leader]
GO
/****** Object: ForeignKey [FK_Link_Node_Location] Script Date: 02/26/2009 15:45:53 ******/
ALTER TABLE [dbo].[Link] WITH CHECK ADD CONSTRAINT [FK_Link_Node_Location] FOREIGN KEY([LocationID])
REFERENCES [dbo].[Node] ([NodeID])
GO
ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Location]
GO
/****** Object: ForeignKey [FK_Link_Node_Person] Script Date: 02/26/2009 15:45:53 ******/
ALTER TABLE [dbo].[Link] WITH CHECK ADD CONSTRAINT [FK_Link_Node_Person] FOREIGN KEY([PersonID])
REFERENCES [dbo].[Node] ([NodeID])
GO
ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Person]
GO
EDMX: