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