/****** Object:  Table [dbo].[ExtraDataCategory]    Script Date: 01/11/2015 15:50:09 ******/
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[ExtraDataCategory](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](32) COLLATE Hungarian_CI_AS NOT NULL,
 CONSTRAINT [pExtraDataCategory] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]




/****** Object:  Table [dbo].[ExtraData]    Script Date: 12/09/2014 16:44:01 ******/
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON

CREATE TABLE [dbo].[ExtraData](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](16) NOT NULL,
	[DataType] [int] NOT NULL,
	[ProductType] [int] NOT NULL,
	[OrdinalNumber] [int] NOT NULL,
	[CategoryId] [int] NULL,
	[IsPrintable] [bit] NOT NULL CONSTRAINT [dExtraData_IsPrintable]  DEFAULT ((0)),
 CONSTRAINT [pExtraData] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

ALTER TABLE [dbo].[ExtraData]  WITH CHECK ADD  CONSTRAINT [fExtraDataExtraDataCategory] FOREIGN KEY([CategoryId])
REFERENCES [dbo].[ExtraDataCategory] ([Id])
ALTER TABLE [dbo].[ExtraData] CHECK CONSTRAINT [fExtraDataExtraDataCategory]


/****** Object:  Table [dbo].[ExtraDataComboValue]    Script Date: 12/09/2014 16:44:30 ******/
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON

CREATE TABLE [dbo].[ExtraDataComboValue](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[ExtraDataId] [int] NOT NULL,
	[ComboValue] [nvarchar](32) NULL,
 CONSTRAINT [pExtraDataDefaultValue] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]


ALTER TABLE [dbo].[ExtraDataComboValue]  WITH CHECK ADD  CONSTRAINT [fExtraDataComboValueExtraData] FOREIGN KEY([ExtraDataId])
REFERENCES [dbo].[ExtraData] ([Id])
ON DELETE CASCADE
ALTER TABLE [dbo].[ExtraDataComboValue] CHECK CONSTRAINT [fExtraDataComboValueExtraData]



/****** Object:  Table [dbo].[ExtraDataSourceData]    Script Date: 12/09/2014 16:45:29 ******/
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON

CREATE TABLE [dbo].[ExtraDataSourceData](
	[ExtraDataId] [int] NOT NULL,
	[SrcAvatarId] [int] NOT NULL,
	[Value] [nvarchar](max) NULL,
	[ComboValue] [nvarchar](32) NULL,
 CONSTRAINT [pExtraDataSourceData] PRIMARY KEY CLUSTERED 
(
	[ExtraDataId] ASC,
	[SrcAvatarId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]



INSERT INTO [dbo].[TableType] (Id, [Name], IsAvatarOwner, IsFinanceLinkOwner) VALUES (890, 'ExtraData', 0, 0)
INSERT INTO [dbo].[TableType] (Id, [Name], IsAvatarOwner, IsFinanceLinkOwner) VALUES (891, 'ExtraDataComboValue', 0, 0)
INSERT INTO [dbo].[TableType] (Id, [Name], IsAvatarOwner, IsFinanceLinkOwner) VALUES (892, 'ExtraDataSourceData', 0, 0)
INSERT INTO [dbo].[TableType] (Id, [Name], IsAvatarOwner, IsFinanceLinkOwner) VALUES (893, 'ExtraDataCategory', 0, 0)