Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 8687 was 8687, checked in by jkarder, 12 years ago

#1712: initial commit

File size: 7.5 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  CONSTRAINT [PK_dbo.Downtime] PRIMARY KEY ([DowntimeId])
78  )
79CREATE TABLE [dbo].[Job](
80  [JobId] UniqueIdentifier NOT NULL,
81  [Name] VarChar(MAX) NOT NULL,
82  [Description] VarChar(MAX),
83  [ResourceIds] VarChar(MAX),
84  [OwnerUserId] UniqueIdentifier NOT NULL,
85  [DateCreated] DateTime NOT NULL,
86  CONSTRAINT [PK_dbo.Job] PRIMARY KEY ([JobId])
87  )
88CREATE TABLE [dbo].[TaskData](
89  [TaskId] UniqueIdentifier NOT NULL,
90  [Data] VarBinary(MAX) NOT NULL,
91  [LastUpdate] DateTime NOT NULL,
92  CONSTRAINT [PK_dbo.TaskData] PRIMARY KEY ([TaskId])
93  )
94CREATE TABLE [dbo].[PluginData](
95  [PluginDataId] UniqueIdentifier NOT NULL,
96  [PluginId] UniqueIdentifier NOT NULL,
97  [Data] VarBinary(MAX) NOT NULL,
98  [FileName] VarChar(MAX) NOT NULL,
99  CONSTRAINT [PK_dbo.PluginData] PRIMARY KEY ([PluginDataId])
100  )
101CREATE TABLE [dbo].[StateLog](
102  [StateLogId] UniqueIdentifier NOT NULL,
103  [State] VarChar(30) NOT NULL,
104  [DateTime] DateTime NOT NULL,
105  [TaskId] UniqueIdentifier NOT NULL,
106  [UserId] UniqueIdentifier,
107  [SlaveId] UniqueIdentifier,
108  [Exception] VarChar(MAX),
109  CONSTRAINT [PK_dbo.StateLog] PRIMARY KEY ([StateLogId])
110  )
111CREATE TABLE [dbo].[JobPermission](
112  [JobId] UniqueIdentifier NOT NULL,
113  [GrantedUserId] UniqueIdentifier NOT NULL,
114  [GrantedByUserId] UniqueIdentifier NOT NULL,
115  [Permission] VarChar(15) NOT NULL,
116  CONSTRAINT [PK_dbo.JobPermission] PRIMARY KEY ([JobId], [GrantedUserId])
117  )
118CREATE TABLE [Lifecycle](
119  [LifecycleId] Int NOT NULL,
120  [LastCleanup] DateTime NOT NULL,
121  CONSTRAINT [PK_Lifecycle] PRIMARY KEY ([LifecycleId])
122  )
123CREATE TABLE [UserPriority](
124  [UserId] UniqueIdentifier NOT NULL,
125  CONSTRAINT [PK_UserPriority] PRIMARY KEY ([UserId])
126  )
127CREATE TABLE [DeletedJobStatistics](
128  [UserId] UniqueIdentifier NOT NULL,
129  [ExecutionTimeS] float NOT NULL,
130  [ExecutionTimeSFinishedJobs] float NOT NULL,
131  [StartToEndTimeS] float NOT NULL,
132  [DeletedJobStatisticsId] UniqueIdentifier NOT NULL,
133  CONSTRAINT [PK_DeletedJobStatistics] PRIMARY KEY ([DeletedJobStatisticsId])
134  )
135CREATE TABLE [UserStatistics](
136  [StatisticsId] UniqueIdentifier NOT NULL,
137  [UserId] UniqueIdentifier NOT NULL,
138  [ExecutionTimeMs] float NOT NULL,
139  [UsedCores] Int NOT NULL,
140  [ExecutionTimeMsFinishedJobs] float NOT NULL,
141  [StartToEndTimeMs] float NOT NULL,
142  CONSTRAINT [PK_UserStatistics] PRIMARY KEY ([StatisticsId], [UserId])
143  )
144CREATE TABLE [SlaveStatistics](
145  [StatisticsId] UniqueIdentifier NOT NULL,
146  [SlaveId] UniqueIdentifier NOT NULL,
147  [Cores] Int NOT NULL,
148  [FreeCores] Int NOT NULL,
149  [CpuUtilization] float NOT NULL,
150  [Memory] Int NOT NULL,
151  [FreeMemory] Int NOT NULL,
152  CONSTRAINT [PK_SlaveStatistics] PRIMARY KEY ([StatisticsId], [SlaveId])
153  )
154CREATE TABLE [Statistics](
155  [StatisticsId] UniqueIdentifier NOT NULL,
156  [Timestamp] DateTime NOT NULL,
157  CONSTRAINT [PK_Statistics] PRIMARY KEY ([StatisticsId])
158  )
159ALTER TABLE [dbo].[AssignedResources]
160  ADD CONSTRAINT [Resource_AssignedResource] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
161ALTER TABLE [dbo].[AssignedResources]
162  ADD CONSTRAINT [Task_AssignedResource] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
163ALTER TABLE [dbo].[RequiredPlugins]
164  ADD CONSTRAINT [Plugin_RequiredPlugin] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
165ALTER TABLE [dbo].[RequiredPlugins]
166  ADD CONSTRAINT [Task_RequiredPlugin] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
167ALTER TABLE [dbo].[Resource]
168  ADD CONSTRAINT [Resource_Resource] FOREIGN KEY ([ParentResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
169ALTER TABLE [dbo].[ResourcePermission]
170  ADD CONSTRAINT [Resource_ResourcePermission] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
171ALTER TABLE [dbo].[Task]
172  ADD CONSTRAINT [Task_Task] FOREIGN KEY ([ParentTaskId]) REFERENCES [dbo].[Task]([TaskId])
173ALTER TABLE [dbo].[Task]
174  ADD CONSTRAINT [Job_Job] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
175ALTER TABLE [dbo].[Downtime]
176  ADD CONSTRAINT [Resource_Downtime] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
177ALTER TABLE [dbo].[TaskData]
178  ADD CONSTRAINT [Task_TaskData] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
179ALTER TABLE [dbo].[PluginData]
180  ADD CONSTRAINT [Plugin_PluginData] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
181ALTER TABLE [dbo].[StateLog]
182  ADD CONSTRAINT [Task_StateLog] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
183ALTER TABLE [dbo].[StateLog]
184  ADD CONSTRAINT [Resource_StateLog] FOREIGN KEY ([SlaveId]) REFERENCES [dbo].[Resource]([ResourceId])
185ALTER TABLE [dbo].[JobPermission]
186  ADD CONSTRAINT [Job_JobPermission] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
187ALTER TABLE [UserStatistics]
188  ADD CONSTRAINT [Statistics_UserStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
189ALTER TABLE [SlaveStatistics]
190  ADD CONSTRAINT [Statistics_SlaveStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
Note: See TracBrowser for help on using the repository browser.