Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Initialize Hive Database_SQL Azure.sql @ 12394

Last change on this file since 12394 was 9363, checked in by spimming, 12 years ago

#1888:

  • Merged revisions from trunk
File size: 7.5 KB
Line 
1/* create and initialize hive database tables */
2
3SET ARITHABORT ON
4CREATE TABLE [dbo].[AssignedResources](
5  [ResourceId] UniqueIdentifier NOT NULL,
6  [TaskId] UniqueIdentifier NOT NULL,
7  CONSTRAINT [PK_dbo.ResourceIdTaskId] PRIMARY KEY ([ResourceId], [TaskId])
8  )
9CREATE TABLE [dbo].[Plugin](
10  [PluginId] UniqueIdentifier NOT NULL,
11  [Name] VarChar(MAX) NOT NULL,
12  [Version] VarChar(MAX) NOT NULL,
13  [UserId] UniqueIdentifier NOT NULL,
14  [DateCreated] DateTime NOT NULL,
15  [Hash] VarBinary(20) NOT NULL,
16  CONSTRAINT [PK_dbo.Plugin] PRIMARY KEY ([PluginId])
17  )
18CREATE TABLE [dbo].[RequiredPlugins](
19  [RequiredPluginId] UniqueIdentifier NOT NULL,
20  [TaskId] UniqueIdentifier NOT NULL,
21  [PluginId] UniqueIdentifier NOT NULL,
22  CONSTRAINT [PK_dbo.RequiredPlugins] PRIMARY KEY ([RequiredPluginId])
23  )
24CREATE TABLE [dbo].[Resource](
25  [ResourceId] UniqueIdentifier NOT NULL,
26  [Name] VarChar(MAX) NOT NULL,
27  [ResourceType] NVarChar(4000) NOT NULL,
28  [ParentResourceId] UniqueIdentifier,
29  [CpuSpeed] Int,
30  [Memory] Int,
31  [Login] DateTime,
32  [SlaveState] VarChar(15),
33  [Cores] Int,
34  [FreeCores] Int,
35  [FreeMemory] Int,
36  [IsAllowedToCalculate] Bit,
37  [CpuArchitecture] VarChar(3),
38  [OperatingSystem] VarChar(MAX),
39  [LastHeartbeat] DateTime,
40  [CpuUtilization] float,
41  [HbInterval] int NOT NULL,
42  [IsDisposable] Bit,
43  [OwnerUserId] UniqueIdentifier,
44  CONSTRAINT [PK_dbo.Resource] PRIMARY KEY ([ResourceId])
45  )
46CREATE TABLE [dbo].[ResourcePermission](
47  [ResourceId] UniqueIdentifier NOT NULL,
48  [GrantedUserId] UniqueIdentifier NOT NULL,
49  [GrantedByUserId] UniqueIdentifier NOT NULL,
50  CONSTRAINT [PK_dbo.ResourcePermission] PRIMARY KEY ([ResourceId], [GrantedUserId])
51  )
52CREATE TABLE [dbo].[Task](
53  [TaskId] UniqueIdentifier NOT NULL,
54  [TaskState] VarChar(30) NOT NULL,
55  [ExecutionTimeMs] float NOT NULL,
56  [LastHeartbeat] DateTime,
57  [ParentTaskId] UniqueIdentifier,
58  [Priority] Int NOT NULL,
59  [CoresNeeded] Int NOT NULL,
60  [MemoryNeeded] Int NOT NULL,
61  [IsParentTask] Bit NOT NULL,
62  [FinishWhenChildJobsFinished] Bit NOT NULL,
63  [Command] VarChar(30),
64  [JobId] UniqueIdentifier NOT NULL,
65  [IsPrivileged] Bit NOT NULL,
66  CONSTRAINT [PK_dbo.Task] PRIMARY KEY ([TaskId])
67  )
68CREATE TABLE [dbo].[Downtime](
69  [DowntimeId] UniqueIdentifier NOT NULL,
70  [ResourceId] UniqueIdentifier NOT NULL,
71  [StartDate] DateTime NOT NULL,
72  [EndDate] DateTime NOT NULL,
73  [AllDayEvent] Bit NOT NULL,
74  [Recurring] Bit NOT NULL,
75  [RecurringId] UniqueIdentifier NOT NULL,
76  [DowntimeType] VarChar(MAX) 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  [DateEnqueued] DateTime NOT NULL,
126  CONSTRAINT [PK_UserPriority] PRIMARY KEY ([UserId])
127  )
128CREATE TABLE [DeletedJobStatistics](
129  [UserId] UniqueIdentifier NOT NULL,
130  [ExecutionTimeS] float NOT NULL,
131  [ExecutionTimeSFinishedJobs] float NOT NULL,
132  [StartToEndTimeS] float NOT NULL,
133  [DeletedJobStatisticsId] UniqueIdentifier NOT NULL,
134  CONSTRAINT [PK_DeletedJobStatistics] PRIMARY KEY ([DeletedJobStatisticsId])
135  )
136CREATE TABLE [UserStatistics](
137  [StatisticsId] UniqueIdentifier NOT NULL,
138  [UserId] UniqueIdentifier NOT NULL,
139  [ExecutionTimeMs] float NOT NULL,
140  [UsedCores] Int NOT NULL,
141  [ExecutionTimeMsFinishedJobs] float NOT NULL,
142  [StartToEndTimeMs] float NOT NULL,
143  CONSTRAINT [PK_UserStatistics] PRIMARY KEY ([StatisticsId], [UserId])
144  )
145CREATE TABLE [SlaveStatistics](
146  [StatisticsId] UniqueIdentifier NOT NULL,
147  [SlaveId] UniqueIdentifier NOT NULL,
148  [Cores] Int NOT NULL,
149  [FreeCores] Int NOT NULL,
150  [CpuUtilization] float NOT NULL,
151  [Memory] Int NOT NULL,
152  [FreeMemory] Int NOT NULL,
153  CONSTRAINT [PK_SlaveStatistics] PRIMARY KEY ([StatisticsId], [SlaveId])
154  )
155CREATE TABLE [Statistics](
156  [StatisticsId] UniqueIdentifier NOT NULL,
157  [Timestamp] DateTime NOT NULL,
158  CONSTRAINT [PK_Statistics] PRIMARY KEY ([StatisticsId])
159  )
160ALTER TABLE [dbo].[AssignedResources]
161  ADD CONSTRAINT [Resource_AssignedResource] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
162ALTER TABLE [dbo].[AssignedResources]
163  ADD CONSTRAINT [Task_AssignedResource] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
164ALTER TABLE [dbo].[RequiredPlugins]
165  ADD CONSTRAINT [Plugin_RequiredPlugin] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
166ALTER TABLE [dbo].[RequiredPlugins]
167  ADD CONSTRAINT [Task_RequiredPlugin] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
168ALTER TABLE [dbo].[Resource]
169  ADD CONSTRAINT [Resource_Resource] FOREIGN KEY ([ParentResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
170ALTER TABLE [dbo].[ResourcePermission]
171  ADD CONSTRAINT [Resource_ResourcePermission] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
172ALTER TABLE [dbo].[Task]
173  ADD CONSTRAINT [Task_Task] FOREIGN KEY ([ParentTaskId]) REFERENCES [dbo].[Task]([TaskId])
174ALTER TABLE [dbo].[Task]
175  ADD CONSTRAINT [Job_Job] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
176ALTER TABLE [dbo].[Downtime]
177  ADD CONSTRAINT [Resource_Downtime] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
178ALTER TABLE [dbo].[TaskData]
179  ADD CONSTRAINT [Task_TaskData] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
180ALTER TABLE [dbo].[PluginData]
181  ADD CONSTRAINT [Plugin_PluginData] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
182ALTER TABLE [dbo].[StateLog]
183  ADD CONSTRAINT [Task_StateLog] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
184ALTER TABLE [dbo].[StateLog]
185  ADD CONSTRAINT [Resource_StateLog] FOREIGN KEY ([SlaveId]) REFERENCES [dbo].[Resource]([ResourceId])
186ALTER TABLE [dbo].[JobPermission]
187  ADD CONSTRAINT [Job_JobPermission] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
188ALTER TABLE [UserStatistics]
189  ADD CONSTRAINT [Statistics_UserStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
190ALTER TABLE [SlaveStatistics]
191  ADD CONSTRAINT [Statistics_SlaveStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId])
Note: See TracBrowser for help on using the repository browser.