Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Initialize Hive Database.sql @ 6721

Last change on this file since 6721 was 6721, checked in by ascheibe, 13 years ago

#1233 Review comments: renamed Job to Task

File size: 7.0 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),
13  [Version] VarChar(MAX),
14  [UserId] UniqueIdentifier,
15  [DateCreated] DateTime,
16  [Hash] VarBinary(20),
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),
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  CONSTRAINT [PK_dbo.Resource] PRIMARY KEY ([ResourceId])
43  )
44CREATE TABLE [dbo].[Task](
45  [TaskId] UniqueIdentifier NOT NULL,
46  [TaskState] VarChar(30),
47  [ExecutionTimeMs] float,
48  [LastHeartbeat] DateTime,
49  [ParentTaskId] UniqueIdentifier,
50  [Priority] Int NOT NULL,
51  [CoresNeeded] Int NOT NULL,
52  [MemoryNeeded] Int NOT NULL,
53  [IsParentTask] Bit,
54  [FinishWhenChildJobsFinished] Bit,
55  [Command] VarChar(30),
56  [HiveExperimentId] UniqueIdentifier NOT NULL,
57  [IsPrivileged] Bit,
58  CONSTRAINT [PK_dbo.Task] PRIMARY KEY ([TaskId])
59  )
60CREATE TABLE [dbo].[Downtime](
61  [DowntimeId] UniqueIdentifier,
62  [ResourceId] UniqueIdentifier,
63  [StartDate] DateTime,
64  [EndDate] DateTime,
65  [AllDayEvent] Bit,
66  [Recurring] Bit,
67  [RecurringId] UniqueIdentifier,
68  CONSTRAINT [PK_dbo.Downtime] PRIMARY KEY ([DowntimeId])
69  )
70CREATE TABLE [dbo].[HiveExperiment](
71  [HiveExperimentId] UniqueIdentifier NOT NULL,
72  [Name] VarChar(MAX),
73  [Description] VarChar(MAX),
74  [ResourceIds] VarChar(MAX),
75  [OwnerUserId] UniqueIdentifier,
76  [DateCreated] DateTime,
77  [LastAccessed] DateTime,
78  [IsHiveEngine] Bit,
79  CONSTRAINT [PK_dbo.HiveExperiment] PRIMARY KEY ([HiveExperimentId])
80  )
81CREATE TABLE [dbo].[TaskData](
82  [TaskId] UniqueIdentifier NOT NULL,
83  [Data] VarBinary(MAX),
84  [LastUpdate] DateTime,
85  CONSTRAINT [PK_dbo.TaskData] PRIMARY KEY ([TaskId])
86  )
87CREATE TABLE [dbo].[PluginData](
88  [PluginDataId] UniqueIdentifier NOT NULL,
89  [PluginId] UniqueIdentifier NOT NULL,
90  [Data] VarBinary(MAX) NOT NULL,
91  [FileName] VarChar(MAX),
92  CONSTRAINT [PK_dbo.PluginData] PRIMARY KEY ([PluginDataId])
93  )
94CREATE TABLE [dbo].[StateLog](
95  [StateLogId] UniqueIdentifier NOT NULL,
96  [State] VarChar(30) NOT NULL,
97  [DateTime] DateTime NOT NULL,
98  [TaskId] UniqueIdentifier NOT NULL,
99  [UserId] UniqueIdentifier,
100  [SlaveId] UniqueIdentifier,
101  [Exception] VarChar(MAX),
102  CONSTRAINT [PK_dbo.StateLog] PRIMARY KEY ([StateLogId])
103  )
104CREATE TABLE [dbo].[HiveExperimentPermission](
105  [HiveExperimentId] UniqueIdentifier NOT NULL,
106  [GrantedUserId] UniqueIdentifier NOT NULL,
107  [GrantedByUserId] UniqueIdentifier NOT NULL,
108  [Permission] VarChar(15) NOT NULL,
109  CONSTRAINT [PK_dbo.HiveExperimentPermission] PRIMARY KEY ([HiveExperimentId], [GrantedUserId])
110  )
111CREATE TABLE [Lifecycle](
112  [LifecycleId] Int,
113  [LastCleanup] DateTime,
114  CONSTRAINT [PK_Lifecycle] PRIMARY KEY ([LifecycleId])
115  )
116CREATE TABLE [DeletedJobStatistics](
117  [UserId] UniqueIdentifier NOT NULL,
118  [ExecutionTimeMs] float NOT NULL,
119  [ExecutionTimeMsFinishedJobs] float NOT NULL,
120  [StartToEndTimeMs] float NOT NULL,
121  [DeletedJobStatisticsId] UniqueIdentifier NOT NULL,
122  CONSTRAINT [PK_DeletedJobStatistics] PRIMARY KEY ([DeletedJobStatisticsId])
123  )
124CREATE TABLE [UserStatistics](
125  [StatisticsId] UniqueIdentifier NOT NULL,
126  [UserId] UniqueIdentifier NOT NULL,
127  [ExecutionTimeMs] float NOT NULL,
128  [UsedCores] Int NOT NULL,
129  [ExecutionTimeMsFinishedJobs] float NOT NULL,
130  [StartToEndTimeMs] float NOT NULL,
131  CONSTRAINT [PK_UserStatistics] PRIMARY KEY ([StatisticsId], [UserId])
132  )
133CREATE TABLE [SlaveStatistics](
134  [StatisticsId] UniqueIdentifier NOT NULL,
135  [SlaveId] UniqueIdentifier NOT NULL,
136  [Cores] Int NOT NULL,
137  [FreeCores] Int NOT NULL,
138  [CpuUtilization] float NOT NULL,
139  [Memory] Int NOT NULL,
140  [FreeMemory] Int NOT NULL,
141  CONSTRAINT [PK_SlaveStatistics] PRIMARY KEY ([StatisticsId], [SlaveId])
142  )
143CREATE TABLE [Statistics](
144  [StatisticsId] UniqueIdentifier NOT NULL,
145  [Timestamp] DateTime NOT NULL,
146  CONSTRAINT [PK_Statistics] PRIMARY KEY ([StatisticsId])
147  )
148ALTER TABLE [dbo].[AssignedResources]
149  ADD CONSTRAINT [Resource_AssignedResource] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
150ALTER TABLE [dbo].[AssignedResources]
151  ADD CONSTRAINT [Task_AssignedResource] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
152ALTER TABLE [dbo].[RequiredPlugins]
153  ADD CONSTRAINT [Plugin_RequiredPlugin] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
154ALTER TABLE [dbo].[RequiredPlugins]
155  ADD CONSTRAINT [Task_RequiredPlugin] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
156ALTER TABLE [dbo].[Resource]
157  ADD CONSTRAINT [Resource_Resource] FOREIGN KEY ([ParentResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
158ALTER TABLE [dbo].[Task]
159  ADD CONSTRAINT [Task_Task] FOREIGN KEY ([ParentTaskId]) REFERENCES [dbo].[Task]([TaskId])
160ALTER TABLE [dbo].[Task]
161  ADD CONSTRAINT [HiveExperiment_Job] FOREIGN KEY ([HiveExperimentId]) REFERENCES [dbo].[HiveExperiment]([HiveExperimentId])
162ALTER TABLE [dbo].[Downtime]
163  ADD CONSTRAINT [Resource_Downtime] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
164ALTER TABLE [dbo].[TaskData]
165  ADD CONSTRAINT [Task_TaskData] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
166ALTER TABLE [dbo].[PluginData]
167  ADD CONSTRAINT [Plugin_PluginData] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
168ALTER TABLE [dbo].[StateLog]
169  ADD CONSTRAINT [Task_StateLog] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
170ALTER TABLE [dbo].[StateLog]
171  ADD CONSTRAINT [Resource_StateLog] FOREIGN KEY ([SlaveId]) REFERENCES [dbo].[Resource]([ResourceId])
172ALTER TABLE [dbo].[HiveExperimentPermission]
173  ADD CONSTRAINT [HiveExperiment_HiveExperimentPermission] FOREIGN KEY ([HiveExperimentId]) REFERENCES [dbo].[HiveExperiment]([HiveExperimentId])
174ALTER TABLE [UserStatistics]
175  ADD CONSTRAINT [Statistics_UserStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
176ALTER TABLE [SlaveStatistics]
177  ADD CONSTRAINT [Statistics_SlaveStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
Note: See TracBrowser for help on using the repository browser.