USE [master]
GO
/****** Object:  Database [TALENTRACKDATA.MDF]    Script Date: 05.09.2015 02:39:46 ******/
CREATE DATABASE [TALENTRACKDATA.MDF]
 GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET COMPATIBILITY_LEVEL = 110
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [TALENTRACKDATA.MDF].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET ARITHABORT OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET AUTO_CLOSE ON 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET AUTO_SHRINK ON 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET  DISABLE_BROKER 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET  MULTI_USER 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET DB_CHAINING OFF 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO
USE [TALENTRACKDATA.MDF]
GO
/****** Object:  Table [dbo].[Applicant]    Script Date: 05.09.2015 02:39:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Applicant](
	[IdApplicant] [nchar](13) NOT NULL,
	[NameApplicant] [nchar](10) NOT NULL,
	[SurnameApplicant] [nchar](10) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[IdApplicant] 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
/****** Object:  Table [dbo].[Employee]    Script Date: 05.09.2015 02:39:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Employee](
	[IdEmployee] [nchar](13) NOT NULL,
	[NameEmployee] [nchar](10) NOT NULL,
	[SurnameEmployee] [nchar](10) NOT NULL,
	[Contact] [nvarchar](50) NOT NULL,
	[NameTitle] [nchar](100) NOT NULL,
	[Status] [nchar](10) NULL,
PRIMARY KEY CLUSTERED 
(
	[IdEmployee] 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
/****** Object:  Table [dbo].[EmployeeSkills]    Script Date: 05.09.2015 02:39:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EmployeeSkills](
	[IdEmployee] [nchar](13) NOT NULL,
	[NameSkill] [nchar](50) NOT NULL,
	[Rating] [decimal](18, 2) NOT NULL,
 CONSTRAINT [PK_EmployeeSkills] PRIMARY KEY CLUSTERED 
(
	[IdEmployee] ASC,
	[NameSkill] 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
/****** Object:  Table [dbo].[Jobs]    Script Date: 05.09.2015 02:39:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Jobs](
	[IdJob] [int] IDENTITY(1,1) NOT NULL,
	[Information] [nvarchar](max) NOT NULL,
	[NameJob] [nchar](100) NOT NULL,
	[Date] [datetime] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[IdJob] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[JobsApplicants]    Script Date: 05.09.2015 02:39:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[JobsApplicants](
	[IdJob] [int] NOT NULL,
	[IdApplicant] [nchar](13) NOT NULL,
 CONSTRAINT [PK_JobsApplicants] PRIMARY KEY CLUSTERED 
(
	[IdJob] ASC,
	[IdApplicant] 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
/****** Object:  Table [dbo].[Skills]    Script Date: 05.09.2015 02:39:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Skills](
	[NameSkill] [nchar](50) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[NameSkill] 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
/****** Object:  Table [dbo].[Title]    Script Date: 05.09.2015 02:39:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Title](
	[NameTitle] [nchar](100) NOT NULL,
	[Salary] [int] NOT NULL,
	[hasAccount] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[NameTitle] 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
/****** Object:  Table [dbo].[User]    Script Date: 05.09.2015 02:39:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[User](
	[IdUser] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nchar](50) NULL,
	[Password] [nchar](50) NULL,
	[Role] [nchar](10) NOT NULL,
	[idEmployee] [nchar](13) NOT NULL,
	[AccountFlag] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[IdUser] 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].[Employee]  WITH CHECK ADD  CONSTRAINT [FK_Employee_Title] FOREIGN KEY([NameTitle])
REFERENCES [dbo].[Title] ([NameTitle])
GO
ALTER TABLE [dbo].[Employee] CHECK CONSTRAINT [FK_Employee_Title]
GO
ALTER TABLE [dbo].[EmployeeSkills]  WITH CHECK ADD  CONSTRAINT [FK_EmployeeSkills_Employee] FOREIGN KEY([IdEmployee])
REFERENCES [dbo].[Employee] ([IdEmployee])
GO
ALTER TABLE [dbo].[EmployeeSkills] CHECK CONSTRAINT [FK_EmployeeSkills_Employee]
GO
ALTER TABLE [dbo].[EmployeeSkills]  WITH CHECK ADD  CONSTRAINT [FK_EmployeeSkills_Skills] FOREIGN KEY([NameSkill])
REFERENCES [dbo].[Skills] ([NameSkill])
GO
ALTER TABLE [dbo].[EmployeeSkills] CHECK CONSTRAINT [FK_EmployeeSkills_Skills]
GO
ALTER TABLE [dbo].[JobsApplicants]  WITH NOCHECK ADD  CONSTRAINT [FK_JobsApplicants_Applicant] FOREIGN KEY([IdApplicant])
REFERENCES [dbo].[Applicant] ([IdApplicant])
GO
ALTER TABLE [dbo].[JobsApplicants] CHECK CONSTRAINT [FK_JobsApplicants_Applicant]
GO
ALTER TABLE [dbo].[JobsApplicants]  WITH NOCHECK ADD  CONSTRAINT [FK_JobsApplicants_Jobs] FOREIGN KEY([IdJob])
REFERENCES [dbo].[Jobs] ([IdJob])
GO
ALTER TABLE [dbo].[JobsApplicants] CHECK CONSTRAINT [FK_JobsApplicants_Jobs]
GO
ALTER TABLE [dbo].[User]  WITH CHECK ADD  CONSTRAINT [FK_User_Employee] FOREIGN KEY([idEmployee])
REFERENCES [dbo].[Employee] ([IdEmployee])
GO
ALTER TABLE [dbo].[User] CHECK CONSTRAINT [FK_User_Employee]
GO
USE [master]
GO
ALTER DATABASE [TALENTRACKDATA.MDF] SET  READ_WRITE 
GO
