Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 8995 was 8995, checked in by ascheibe, 12 years ago

#1712 merged trunk into branch

File size: 7.6 KB
Line 
1USE [HeuristicLab.Hive-3.3]
2/* create and initialize hive database tables */
3
4SET ARITHABORT ON
5CREATE TABLE [dbo].[AssignedResources](
6  [ResourceId] UniqueIdentifier NOT NULL,
7  [TaskId] UniqueIdentifier NOT NULL,
8  CONSTRAINT [PK_dbo.ResourceIdTaskId] PRIMARY KEY ([ResourceId], [TaskId])
9  )
10CREATE TABLE [dbo].[Plugin](
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,
17  CONSTRAINT [PK_dbo.Plugin] PRIMARY KEY ([PluginId])
18  )
19CREATE TABLE [dbo].[RequiredPlugins](
20  [RequiredPluginId] UniqueIdentifier NOT NULL,
21  [TaskId] UniqueIdentifier NOT NULL,
22  [PluginId] UniqueIdentifier NOT NULL,
23  CONSTRAINT [PK_dbo.RequiredPlugins] PRIMARY KEY ([RequiredPluginId])
24  )
25CREATE TABLE [dbo].[Resource](
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,
43  [IsDisposable] Bit,
44  [OwnerUserId] UniqueIdentifier,
45  CONSTRAINT [PK_dbo.Resource] PRIMARY KEY ([ResourceId])
46  )
47CREATE 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  )
53CREATE TABLE [dbo].[Task](
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,
67  CONSTRAINT [PK_dbo.Task] PRIMARY KEY ([TaskId])
68  )
69CREATE TABLE [dbo].[Downtime](
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,
77  [DowntimeType] VarChar(MAX) NOT NULL,
78  CONSTRAINT [PK_dbo.Downtime] PRIMARY KEY ([DowntimeId])
79  )
80CREATE TABLE [dbo].[Job](
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,
87  CONSTRAINT [PK_dbo.Job] PRIMARY KEY ([JobId])
88  )
89CREATE TABLE [dbo].[TaskData](
90  [TaskId] UniqueIdentifier NOT NULL,
91  [Data] VarBinary(MAX) NOT NULL,
92  [LastUpdate] DateTime NOT NULL,
93  CONSTRAINT [PK_dbo.TaskData] PRIMARY KEY ([TaskId])
94  )
95CREATE TABLE [dbo].[PluginData](
96  [PluginDataId] UniqueIdentifier NOT NULL,
97  [PluginId] UniqueIdentifier NOT NULL,
98  [Data] VarBinary(MAX) NOT NULL,
99  [FileName] VarChar(MAX) NOT NULL,
100  CONSTRAINT [PK_dbo.PluginData] PRIMARY KEY ([PluginDataId])
101  )
102CREATE TABLE [dbo].[StateLog](
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),
110  CONSTRAINT [PK_dbo.StateLog] PRIMARY KEY ([StateLogId])
111  )
112CREATE TABLE [dbo].[JobPermission](
113  [JobId] UniqueIdentifier NOT NULL,
114  [GrantedUserId] UniqueIdentifier NOT NULL,
115  [GrantedByUserId] UniqueIdentifier NOT NULL,
116  [Permission] VarChar(15) NOT NULL,
117  CONSTRAINT [PK_dbo.JobPermission] PRIMARY KEY ([JobId], [GrantedUserId])
118  )
119CREATE TABLE [Lifecycle](
120  [LifecycleId] Int NOT NULL,
121  [LastCleanup] DateTime NOT NULL,
122  CONSTRAINT [PK_Lifecycle] PRIMARY KEY ([LifecycleId])
123  )
124CREATE TABLE [UserPriority](
125  [UserId] UniqueIdentifier NOT NULL,
126  [DateEnqueued] DateTime NOT NULL,
127  CONSTRAINT [PK_UserPriority] PRIMARY KEY ([UserId])
128  )
129CREATE TABLE [DeletedJobStatistics](
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,
135  CONSTRAINT [PK_DeletedJobStatistics] PRIMARY KEY ([DeletedJobStatisticsId])
136  )
137CREATE TABLE [UserStatistics](
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,
144  CONSTRAINT [PK_UserStatistics] PRIMARY KEY ([StatisticsId], [UserId])
145  )
146CREATE TABLE [SlaveStatistics](
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,
154  CONSTRAINT [PK_SlaveStatistics] PRIMARY KEY ([StatisticsId], [SlaveId])
155  )
156CREATE TABLE [Statistics](
157  [StatisticsId] UniqueIdentifier NOT NULL,
158  [Timestamp] DateTime NOT NULL,
159  CONSTRAINT [PK_Statistics] PRIMARY KEY ([StatisticsId])
160  )
161ALTER TABLE [dbo].[AssignedResources]
162  ADD CONSTRAINT [Resource_AssignedResource] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
163ALTER TABLE [dbo].[AssignedResources]
164  ADD CONSTRAINT [Task_AssignedResource] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
165ALTER TABLE [dbo].[RequiredPlugins]
166  ADD CONSTRAINT [Plugin_RequiredPlugin] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
167ALTER TABLE [dbo].[RequiredPlugins]
168  ADD CONSTRAINT [Task_RequiredPlugin] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
169ALTER TABLE [dbo].[Resource]
170  ADD CONSTRAINT [Resource_Resource] FOREIGN KEY ([ParentResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
171ALTER TABLE [dbo].[ResourcePermission]
172  ADD CONSTRAINT [Resource_ResourcePermission] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
173ALTER TABLE [dbo].[Task]
174  ADD CONSTRAINT [Task_Task] FOREIGN KEY ([ParentTaskId]) REFERENCES [dbo].[Task]([TaskId])
175ALTER TABLE [dbo].[Task]
176  ADD CONSTRAINT [Job_Job] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
177ALTER TABLE [dbo].[Downtime]
178  ADD CONSTRAINT [Resource_Downtime] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
179ALTER TABLE [dbo].[TaskData]
180  ADD CONSTRAINT [Task_TaskData] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
181ALTER TABLE [dbo].[PluginData]
182  ADD CONSTRAINT [Plugin_PluginData] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
183ALTER TABLE [dbo].[StateLog]
184  ADD CONSTRAINT [Task_StateLog] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
185ALTER TABLE [dbo].[StateLog]
186  ADD CONSTRAINT [Resource_StateLog] FOREIGN KEY ([SlaveId]) REFERENCES [dbo].[Resource]([ResourceId])
187ALTER TABLE [dbo].[JobPermission]
188  ADD CONSTRAINT [Job_JobPermission] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
189ALTER TABLE [UserStatistics]
190  ADD CONSTRAINT [Statistics_UserStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
191ALTER TABLE [SlaveStatistics]
192  ADD CONSTRAINT [Statistics_SlaveStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
Note: See TracBrowser for help on using the repository browser.