if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[poll]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[poll]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[votelog]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[votelog]
GO

CREATE TABLE [dbo].[poll] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[question] [nvarchar] (255) NULL ,
	[answer1] [nvarchar] (50) NULL ,
	[count1] [int] NULL ,
	[answer2] [nvarchar] (50) NULL ,
	[count2] [int] NULL ,
	[answer3] [nvarchar] (50) NULL ,
	[count3] [int] NULL ,
	[answer4] [nvarchar] (50) NULL ,
	[count4] [int] NULL ,
	[answer5] [nvarchar] (50) NULL ,
	[count5] [int] NULL ,
	[answer6] [nvarchar] (50) NULL ,
	[count6] [int] NULL ,
	[answer7] [nvarchar] (50) NULL ,
	[count7] [int] NULL ,
	[answer8] [nvarchar] (50) NULL ,
	[count8] [int] NULL ,
	[createdwhen] [datetime] NULL ,
	[active] [bit] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[votelog] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[poll_id] [int] NULL ,
	[ip] [nvarchar] (20) NULL ,
	[datum] AS (getdate()) 
) ON [PRIMARY]
GO

 CREATE  INDEX [ix1] ON [dbo].[poll]([id]) ON [PRIMARY]
GO

 CREATE  INDEX [ix1] ON [dbo].[votelog]([poll_id]) ON [PRIMARY]
GO

