Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Initialize Hive Database.sql @ 10479

Last change on this file since 10479 was 9665, checked in by ascheibe, 11 years ago

#2030 merged hive performance branch back into trunk

File size: 7.7 KB
Line 
1USE [HeuristicLab.Hive-3.3]
2/* create and initialize hive database tables */
3
4EXEC sp_configure filestream_access_level, 2
5GO
6RECONFIGURE
7GO
8
9SET ARITHABORT ON
10CREATE TABLE [dbo].[AssignedResources](
11  [ResourceId] UniqueIdentifier NOT NULL,
12  [TaskId] UniqueIdentifier NOT NULL,
13  CONSTRAINT [PK_dbo.ResourceIdTaskId] PRIMARY KEY ([ResourceId], [TaskId])
14  )
15CREATE TABLE [dbo].[Plugin](
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,
22  CONSTRAINT [PK_dbo.Plugin] PRIMARY KEY ([PluginId])
23  )
24CREATE TABLE [dbo].[RequiredPlugins](
25  [RequiredPluginId] UniqueIdentifier NOT NULL,
26  [TaskId] UniqueIdentifier NOT NULL,
27  [PluginId] UniqueIdentifier NOT NULL,
28  CONSTRAINT [PK_dbo.RequiredPlugins] PRIMARY KEY ([RequiredPluginId])
29  )
30CREATE TABLE [dbo].[Resource](
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,
48  [IsDisposable] Bit,
49  [OwnerUserId] UniqueIdentifier,
50  CONSTRAINT [PK_dbo.Resource] PRIMARY KEY ([ResourceId])
51  )
52CREATE 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  )
58CREATE TABLE [dbo].[Task](
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,
72  CONSTRAINT [PK_dbo.Task] PRIMARY KEY ([TaskId])
73  )
74CREATE TABLE [dbo].[Downtime](
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,
82  [DowntimeType] VarChar(MAX) NOT NULL,
83  CONSTRAINT [PK_dbo.Downtime] PRIMARY KEY ([DowntimeId])
84  )
85CREATE TABLE [dbo].[Job](
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,
92  CONSTRAINT [PK_dbo.Job] PRIMARY KEY ([JobId])
93  )
94CREATE TABLE [dbo].[TaskData](
95  [TaskId] UniqueIdentifier RowGuidCol NOT NULL,
96  [Data] VarBinary(MAX) Filestream NOT NULL,
97  [LastUpdate] DateTime NOT NULL,
98  CONSTRAINT [PK_dbo.TaskData] PRIMARY KEY ([TaskId])
99  )
100CREATE TABLE [dbo].[PluginData](
101  [PluginDataId] UniqueIdentifier RowGuidCol NOT NULL,
102  [PluginId] UniqueIdentifier NOT NULL,
103  [Data] VarBinary(MAX) FileStream NOT NULL,
104  [FileName] VarChar(MAX) NOT NULL,
105  CONSTRAINT [PK_dbo.PluginData] PRIMARY KEY ([PluginDataId])
106  )
107CREATE TABLE [dbo].[StateLog](
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),
115  CONSTRAINT [PK_dbo.StateLog] PRIMARY KEY ([StateLogId])
116  )
117CREATE TABLE [dbo].[JobPermission](
118  [JobId] UniqueIdentifier NOT NULL,
119  [GrantedUserId] UniqueIdentifier NOT NULL,
120  [GrantedByUserId] UniqueIdentifier NOT NULL,
121  [Permission] VarChar(15) NOT NULL,
122  CONSTRAINT [PK_dbo.JobPermission] PRIMARY KEY ([JobId], [GrantedUserId])
123  )
124CREATE TABLE [Lifecycle](
125  [LifecycleId] Int NOT NULL,
126  [LastCleanup] DateTime NOT NULL,
127  CONSTRAINT [PK_Lifecycle] PRIMARY KEY ([LifecycleId])
128  )
129CREATE TABLE [UserPriority](
130  [UserId] UniqueIdentifier NOT NULL,
131  [DateEnqueued] DateTime NOT NULL,
132  CONSTRAINT [PK_UserPriority] PRIMARY KEY ([UserId])
133  )
134CREATE TABLE [DeletedJobStatistics](
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,
140  CONSTRAINT [PK_DeletedJobStatistics] PRIMARY KEY ([DeletedJobStatisticsId])
141  )
142CREATE TABLE [UserStatistics](
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,
149  CONSTRAINT [PK_UserStatistics] PRIMARY KEY ([StatisticsId], [UserId])
150  )
151CREATE TABLE [SlaveStatistics](
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,
159  CONSTRAINT [PK_SlaveStatistics] PRIMARY KEY ([StatisticsId], [SlaveId])
160  )
161CREATE TABLE [Statistics](
162  [StatisticsId] UniqueIdentifier NOT NULL,
163  [Timestamp] DateTime NOT NULL,
164  CONSTRAINT [PK_Statistics] PRIMARY KEY ([StatisticsId])
165  )
166ALTER TABLE [dbo].[AssignedResources]
167  ADD CONSTRAINT [Resource_AssignedResource] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
168ALTER TABLE [dbo].[AssignedResources]
169  ADD CONSTRAINT [Task_AssignedResource] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
170ALTER TABLE [dbo].[RequiredPlugins]
171  ADD CONSTRAINT [Plugin_RequiredPlugin] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
172ALTER TABLE [dbo].[RequiredPlugins]
173  ADD CONSTRAINT [Task_RequiredPlugin] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
174ALTER TABLE [dbo].[Resource]
175  ADD CONSTRAINT [Resource_Resource] FOREIGN KEY ([ParentResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
176ALTER TABLE [dbo].[ResourcePermission]
177  ADD CONSTRAINT [Resource_ResourcePermission] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
178ALTER TABLE [dbo].[Task]
179  ADD CONSTRAINT [Task_Task] FOREIGN KEY ([ParentTaskId]) REFERENCES [dbo].[Task]([TaskId])
180ALTER TABLE [dbo].[Task]
181  ADD CONSTRAINT [Job_Job] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
182ALTER TABLE [dbo].[Downtime]
183  ADD CONSTRAINT [Resource_Downtime] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
184ALTER TABLE [dbo].[TaskData]
185  ADD CONSTRAINT [Task_TaskData] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
186ALTER TABLE [dbo].[PluginData]
187  ADD CONSTRAINT [Plugin_PluginData] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
188ALTER TABLE [dbo].[StateLog]
189  ADD CONSTRAINT [Task_StateLog] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
190ALTER TABLE [dbo].[StateLog]
191  ADD CONSTRAINT [Resource_StateLog] FOREIGN KEY ([SlaveId]) REFERENCES [dbo].[Resource]([ResourceId])
192ALTER TABLE [dbo].[JobPermission]
193  ADD CONSTRAINT [Job_JobPermission] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
194ALTER TABLE [UserStatistics]
195  ADD CONSTRAINT [Statistics_UserStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
196ALTER TABLE [SlaveStatistics]
197  ADD CONSTRAINT [Statistics_SlaveStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
Note: See TracBrowser for help on using the repository browser.