[6983] | 1 | USE [HeuristicLab.Hive-3.3]
|
---|
| 2 | /* create and initialize hive database tables */
|
---|
| 3 |
|
---|
[9665] | 4 | EXEC sp_configure filestream_access_level, 2
|
---|
| 5 | GO
|
---|
| 6 | RECONFIGURE
|
---|
| 7 | GO
|
---|
| 8 |
|
---|
[6983] | 9 | SET ARITHABORT ON
|
---|
| 10 | CREATE TABLE [dbo].[AssignedResources](
|
---|
| 11 | [ResourceId] UniqueIdentifier NOT NULL,
|
---|
[7847] | 12 | [TaskId] UniqueIdentifier NOT NULL,
|
---|
[6983] | 13 | CONSTRAINT [PK_dbo.ResourceIdTaskId] PRIMARY KEY ([ResourceId], [TaskId])
|
---|
| 14 | )
|
---|
| 15 | CREATE TABLE [dbo].[Plugin](
|
---|
[7847] | 16 | [PluginId] UniqueIdentifier NOT NULL,
|
---|
| 17 | [Name] VarChar(MAX) NOT NULL,
|
---|
| 18 | [Version] VarChar(MAX) NOT NULL,
|
---|
| 19 | [UserId] UniqueIdentifier NOT NULL,
|
---|
| 20 | [DateCreated] DateTime NOT NULL,
|
---|
| 21 | [Hash] VarBinary(20) NOT NULL,
|
---|
[6983] | 22 | CONSTRAINT [PK_dbo.Plugin] PRIMARY KEY ([PluginId])
|
---|
| 23 | )
|
---|
| 24 | CREATE TABLE [dbo].[RequiredPlugins](
|
---|
[7847] | 25 | [RequiredPluginId] UniqueIdentifier NOT NULL,
|
---|
| 26 | [TaskId] UniqueIdentifier NOT NULL,
|
---|
| 27 | [PluginId] UniqueIdentifier NOT NULL,
|
---|
[6983] | 28 | CONSTRAINT [PK_dbo.RequiredPlugins] PRIMARY KEY ([RequiredPluginId])
|
---|
| 29 | )
|
---|
| 30 | CREATE TABLE [dbo].[Resource](
|
---|
[7847] | 31 | [ResourceId] UniqueIdentifier NOT NULL,
|
---|
| 32 | [Name] VarChar(MAX) NOT NULL,
|
---|
| 33 | [ResourceType] NVarChar(4000) NOT NULL,
|
---|
| 34 | [ParentResourceId] UniqueIdentifier,
|
---|
| 35 | [CpuSpeed] Int,
|
---|
| 36 | [Memory] Int,
|
---|
| 37 | [Login] DateTime,
|
---|
| 38 | [SlaveState] VarChar(15),
|
---|
| 39 | [Cores] Int,
|
---|
| 40 | [FreeCores] Int,
|
---|
| 41 | [FreeMemory] Int,
|
---|
| 42 | [IsAllowedToCalculate] Bit,
|
---|
| 43 | [CpuArchitecture] VarChar(3),
|
---|
| 44 | [OperatingSystem] VarChar(MAX),
|
---|
| 45 | [LastHeartbeat] DateTime,
|
---|
| 46 | [CpuUtilization] float,
|
---|
| 47 | [HbInterval] int NOT NULL,
|
---|
[7857] | 48 | [IsDisposable] Bit,
|
---|
[7916] | 49 | [OwnerUserId] UniqueIdentifier,
|
---|
[6983] | 50 | CONSTRAINT [PK_dbo.Resource] PRIMARY KEY ([ResourceId])
|
---|
| 51 | )
|
---|
[7916] | 52 | CREATE TABLE [dbo].[ResourcePermission](
|
---|
| 53 | [ResourceId] UniqueIdentifier NOT NULL,
|
---|
| 54 | [GrantedUserId] UniqueIdentifier NOT NULL,
|
---|
| 55 | [GrantedByUserId] UniqueIdentifier NOT NULL,
|
---|
| 56 | CONSTRAINT [PK_dbo.ResourcePermission] PRIMARY KEY ([ResourceId], [GrantedUserId])
|
---|
| 57 | )
|
---|
[6983] | 58 | CREATE TABLE [dbo].[Task](
|
---|
[7847] | 59 | [TaskId] UniqueIdentifier NOT NULL,
|
---|
| 60 | [TaskState] VarChar(30) NOT NULL,
|
---|
| 61 | [ExecutionTimeMs] float NOT NULL,
|
---|
| 62 | [LastHeartbeat] DateTime,
|
---|
| 63 | [ParentTaskId] UniqueIdentifier,
|
---|
| 64 | [Priority] Int NOT NULL,
|
---|
| 65 | [CoresNeeded] Int NOT NULL,
|
---|
| 66 | [MemoryNeeded] Int NOT NULL,
|
---|
| 67 | [IsParentTask] Bit NOT NULL,
|
---|
| 68 | [FinishWhenChildJobsFinished] Bit NOT NULL,
|
---|
| 69 | [Command] VarChar(30),
|
---|
| 70 | [JobId] UniqueIdentifier NOT NULL,
|
---|
| 71 | [IsPrivileged] Bit NOT NULL,
|
---|
[6983] | 72 | CONSTRAINT [PK_dbo.Task] PRIMARY KEY ([TaskId])
|
---|
| 73 | )
|
---|
| 74 | CREATE TABLE [dbo].[Downtime](
|
---|
[7847] | 75 | [DowntimeId] UniqueIdentifier NOT NULL,
|
---|
| 76 | [ResourceId] UniqueIdentifier NOT NULL,
|
---|
| 77 | [StartDate] DateTime NOT NULL,
|
---|
| 78 | [EndDate] DateTime NOT NULL,
|
---|
| 79 | [AllDayEvent] Bit NOT NULL,
|
---|
| 80 | [Recurring] Bit NOT NULL,
|
---|
| 81 | [RecurringId] UniqueIdentifier NOT NULL,
|
---|
[8957] | 82 | [DowntimeType] VarChar(MAX) NOT NULL,
|
---|
[6983] | 83 | CONSTRAINT [PK_dbo.Downtime] PRIMARY KEY ([DowntimeId])
|
---|
| 84 | )
|
---|
| 85 | CREATE TABLE [dbo].[Job](
|
---|
[7847] | 86 | [JobId] UniqueIdentifier NOT NULL,
|
---|
| 87 | [Name] VarChar(MAX) NOT NULL,
|
---|
| 88 | [Description] VarChar(MAX),
|
---|
| 89 | [ResourceIds] VarChar(MAX),
|
---|
| 90 | [OwnerUserId] UniqueIdentifier NOT NULL,
|
---|
| 91 | [DateCreated] DateTime NOT NULL,
|
---|
[6983] | 92 | CONSTRAINT [PK_dbo.Job] PRIMARY KEY ([JobId])
|
---|
| 93 | )
|
---|
| 94 | CREATE TABLE [dbo].[TaskData](
|
---|
[9665] | 95 | [TaskId] UniqueIdentifier RowGuidCol NOT NULL,
|
---|
| 96 | [Data] VarBinary(MAX) Filestream NOT NULL,
|
---|
[7847] | 97 | [LastUpdate] DateTime NOT NULL,
|
---|
[6983] | 98 | CONSTRAINT [PK_dbo.TaskData] PRIMARY KEY ([TaskId])
|
---|
| 99 | )
|
---|
| 100 | CREATE TABLE [dbo].[PluginData](
|
---|
[9665] | 101 | [PluginDataId] UniqueIdentifier RowGuidCol NOT NULL,
|
---|
[7847] | 102 | [PluginId] UniqueIdentifier NOT NULL,
|
---|
[9665] | 103 | [Data] VarBinary(MAX) FileStream NOT NULL,
|
---|
[7847] | 104 | [FileName] VarChar(MAX) NOT NULL,
|
---|
[6983] | 105 | CONSTRAINT [PK_dbo.PluginData] PRIMARY KEY ([PluginDataId])
|
---|
| 106 | )
|
---|
| 107 | CREATE TABLE [dbo].[StateLog](
|
---|
[7847] | 108 | [StateLogId] UniqueIdentifier NOT NULL,
|
---|
| 109 | [State] VarChar(30) NOT NULL,
|
---|
| 110 | [DateTime] DateTime NOT NULL,
|
---|
| 111 | [TaskId] UniqueIdentifier NOT NULL,
|
---|
| 112 | [UserId] UniqueIdentifier,
|
---|
| 113 | [SlaveId] UniqueIdentifier,
|
---|
| 114 | [Exception] VarChar(MAX),
|
---|
[6983] | 115 | CONSTRAINT [PK_dbo.StateLog] PRIMARY KEY ([StateLogId])
|
---|
| 116 | )
|
---|
| 117 | CREATE TABLE [dbo].[JobPermission](
|
---|
[7847] | 118 | [JobId] UniqueIdentifier NOT NULL,
|
---|
| 119 | [GrantedUserId] UniqueIdentifier NOT NULL,
|
---|
| 120 | [GrantedByUserId] UniqueIdentifier NOT NULL,
|
---|
| 121 | [Permission] VarChar(15) NOT NULL,
|
---|
[6983] | 122 | CONSTRAINT [PK_dbo.JobPermission] PRIMARY KEY ([JobId], [GrantedUserId])
|
---|
| 123 | )
|
---|
| 124 | CREATE TABLE [Lifecycle](
|
---|
[7847] | 125 | [LifecycleId] Int NOT NULL,
|
---|
| 126 | [LastCleanup] DateTime NOT NULL,
|
---|
[6983] | 127 | CONSTRAINT [PK_Lifecycle] PRIMARY KEY ([LifecycleId])
|
---|
| 128 | )
|
---|
[9123] | 129 | CREATE TABLE [UserPriority](
|
---|
| 130 | [UserId] UniqueIdentifier NOT NULL,
|
---|
| 131 | [DateEnqueued] DateTime NOT NULL,
|
---|
| 132 | CONSTRAINT [PK_UserPriority] PRIMARY KEY ([UserId])
|
---|
| 133 | )
|
---|
[6983] | 134 | CREATE TABLE [DeletedJobStatistics](
|
---|
[7847] | 135 | [UserId] UniqueIdentifier NOT NULL,
|
---|
| 136 | [ExecutionTimeS] float NOT NULL,
|
---|
| 137 | [ExecutionTimeSFinishedJobs] float NOT NULL,
|
---|
| 138 | [StartToEndTimeS] float NOT NULL,
|
---|
| 139 | [DeletedJobStatisticsId] UniqueIdentifier NOT NULL,
|
---|
[6983] | 140 | CONSTRAINT [PK_DeletedJobStatistics] PRIMARY KEY ([DeletedJobStatisticsId])
|
---|
| 141 | )
|
---|
| 142 | CREATE TABLE [UserStatistics](
|
---|
[7847] | 143 | [StatisticsId] UniqueIdentifier NOT NULL,
|
---|
| 144 | [UserId] UniqueIdentifier NOT NULL,
|
---|
| 145 | [ExecutionTimeMs] float NOT NULL,
|
---|
| 146 | [UsedCores] Int NOT NULL,
|
---|
| 147 | [ExecutionTimeMsFinishedJobs] float NOT NULL,
|
---|
| 148 | [StartToEndTimeMs] float NOT NULL,
|
---|
[6983] | 149 | CONSTRAINT [PK_UserStatistics] PRIMARY KEY ([StatisticsId], [UserId])
|
---|
| 150 | )
|
---|
| 151 | CREATE TABLE [SlaveStatistics](
|
---|
[7847] | 152 | [StatisticsId] UniqueIdentifier NOT NULL,
|
---|
| 153 | [SlaveId] UniqueIdentifier NOT NULL,
|
---|
| 154 | [Cores] Int NOT NULL,
|
---|
| 155 | [FreeCores] Int NOT NULL,
|
---|
| 156 | [CpuUtilization] float NOT NULL,
|
---|
| 157 | [Memory] Int NOT NULL,
|
---|
| 158 | [FreeMemory] Int NOT NULL,
|
---|
[6983] | 159 | CONSTRAINT [PK_SlaveStatistics] PRIMARY KEY ([StatisticsId], [SlaveId])
|
---|
| 160 | )
|
---|
| 161 | CREATE TABLE [Statistics](
|
---|
[7847] | 162 | [StatisticsId] UniqueIdentifier NOT NULL,
|
---|
| 163 | [Timestamp] DateTime NOT NULL,
|
---|
[6983] | 164 | CONSTRAINT [PK_Statistics] PRIMARY KEY ([StatisticsId])
|
---|
| 165 | )
|
---|
| 166 | ALTER TABLE [dbo].[AssignedResources]
|
---|
| 167 | ADD CONSTRAINT [Resource_AssignedResource] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
|
---|
| 168 | ALTER TABLE [dbo].[AssignedResources]
|
---|
| 169 | ADD CONSTRAINT [Task_AssignedResource] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
|
---|
| 170 | ALTER TABLE [dbo].[RequiredPlugins]
|
---|
| 171 | ADD CONSTRAINT [Plugin_RequiredPlugin] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
|
---|
| 172 | ALTER TABLE [dbo].[RequiredPlugins]
|
---|
| 173 | ADD CONSTRAINT [Task_RequiredPlugin] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
|
---|
| 174 | ALTER TABLE [dbo].[Resource]
|
---|
| 175 | ADD CONSTRAINT [Resource_Resource] FOREIGN KEY ([ParentResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
|
---|
[7916] | 176 | ALTER TABLE [dbo].[ResourcePermission]
|
---|
| 177 | ADD CONSTRAINT [Resource_ResourcePermission] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
|
---|
[6983] | 178 | ALTER TABLE [dbo].[Task]
|
---|
| 179 | ADD CONSTRAINT [Task_Task] FOREIGN KEY ([ParentTaskId]) REFERENCES [dbo].[Task]([TaskId])
|
---|
| 180 | ALTER TABLE [dbo].[Task]
|
---|
| 181 | ADD CONSTRAINT [Job_Job] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
|
---|
| 182 | ALTER TABLE [dbo].[Downtime]
|
---|
| 183 | ADD CONSTRAINT [Resource_Downtime] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
|
---|
| 184 | ALTER TABLE [dbo].[TaskData]
|
---|
| 185 | ADD CONSTRAINT [Task_TaskData] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
|
---|
| 186 | ALTER TABLE [dbo].[PluginData]
|
---|
| 187 | ADD CONSTRAINT [Plugin_PluginData] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
|
---|
| 188 | ALTER TABLE [dbo].[StateLog]
|
---|
| 189 | ADD CONSTRAINT [Task_StateLog] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
|
---|
| 190 | ALTER TABLE [dbo].[StateLog]
|
---|
| 191 | ADD CONSTRAINT [Resource_StateLog] FOREIGN KEY ([SlaveId]) REFERENCES [dbo].[Resource]([ResourceId])
|
---|
| 192 | ALTER TABLE [dbo].[JobPermission]
|
---|
| 193 | ADD CONSTRAINT [Job_JobPermission] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
|
---|
| 194 | ALTER TABLE [UserStatistics]
|
---|
| 195 | ADD CONSTRAINT [Statistics_UserStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
|
---|
| 196 | ALTER TABLE [SlaveStatistics]
|
---|
| 197 | ADD CONSTRAINT [Statistics_SlaveStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
|
---|