Changeset 6723 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts
- Timestamp:
- 09/08/11 14:37:52 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Initialize Hive Database.sql
r6721 r6723 4 4 SET ARITHABORT ON 5 5 CREATE TABLE [dbo].[AssignedResources]( 6 [ResourceId] UniqueIdentifier NOT NULL, 6 [ResourceId] UniqueIdentifier NOT NULL, 7 7 [TaskId] UniqueIdentifier NOT NULL, 8 8 CONSTRAINT [PK_dbo.ResourceIdTaskId] PRIMARY KEY ([ResourceId], [TaskId]) … … 54 54 [FinishWhenChildJobsFinished] Bit, 55 55 [Command] VarChar(30), 56 [ HiveExperimentId] UniqueIdentifier NOT NULL,56 [JobId] UniqueIdentifier NOT NULL, 57 57 [IsPrivileged] Bit, 58 58 CONSTRAINT [PK_dbo.Task] PRIMARY KEY ([TaskId]) … … 68 68 CONSTRAINT [PK_dbo.Downtime] PRIMARY KEY ([DowntimeId]) 69 69 ) 70 CREATE TABLE [dbo].[ HiveExperiment](71 [ HiveExperimentId] UniqueIdentifier NOT NULL,70 CREATE TABLE [dbo].[Job]( 71 [JobId] UniqueIdentifier NOT NULL, 72 72 [Name] VarChar(MAX), 73 73 [Description] VarChar(MAX), … … 77 77 [LastAccessed] DateTime, 78 78 [IsHiveEngine] Bit, 79 CONSTRAINT [PK_dbo. HiveExperiment] PRIMARY KEY ([HiveExperimentId])79 CONSTRAINT [PK_dbo.Job] PRIMARY KEY ([JobId]) 80 80 ) 81 81 CREATE TABLE [dbo].[TaskData]( … … 102 102 CONSTRAINT [PK_dbo.StateLog] PRIMARY KEY ([StateLogId]) 103 103 ) 104 CREATE TABLE [dbo].[ HiveExperimentPermission](105 [ HiveExperimentId] UniqueIdentifier NOT NULL,104 CREATE TABLE [dbo].[JobPermission]( 105 [JobId] UniqueIdentifier NOT NULL, 106 106 [GrantedUserId] UniqueIdentifier NOT NULL, 107 107 [GrantedByUserId] UniqueIdentifier NOT NULL, 108 108 [Permission] VarChar(15) NOT NULL, 109 CONSTRAINT [PK_dbo. HiveExperimentPermission] PRIMARY KEY ([HiveExperimentId], [GrantedUserId])109 CONSTRAINT [PK_dbo.JobPermission] PRIMARY KEY ([JobId], [GrantedUserId]) 110 110 ) 111 111 CREATE TABLE [Lifecycle]( … … 159 159 ADD CONSTRAINT [Task_Task] FOREIGN KEY ([ParentTaskId]) REFERENCES [dbo].[Task]([TaskId]) 160 160 ALTER TABLE [dbo].[Task] 161 ADD CONSTRAINT [ HiveExperiment_Job] FOREIGN KEY ([HiveExperimentId]) REFERENCES [dbo].[HiveExperiment]([HiveExperimentId])161 ADD CONSTRAINT [Job_Job] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId]) 162 162 ALTER TABLE [dbo].[Downtime] 163 163 ADD CONSTRAINT [Resource_Downtime] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId]) … … 170 170 ALTER TABLE [dbo].[StateLog] 171 171 ADD CONSTRAINT [Resource_StateLog] FOREIGN KEY ([SlaveId]) REFERENCES [dbo].[Resource]([ResourceId]) 172 ALTER TABLE [dbo].[ HiveExperimentPermission]173 ADD CONSTRAINT [ HiveExperiment_HiveExperimentPermission] FOREIGN KEY ([HiveExperimentId]) REFERENCES [dbo].[HiveExperiment]([HiveExperimentId])172 ALTER TABLE [dbo].[JobPermission] 173 ADD CONSTRAINT [Job_JobPermission] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId]) 174 174 ALTER TABLE [UserStatistics] 175 175 ADD CONSTRAINT [Statistics_UserStatistics] FOREIGN KEY ([StatisticsId]) REFERENCES [Statistics]([StatisticsId]) -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Prepare Hive Database.sql
r6721 r6723 74 74 ALTER TABLE dbo.Downtime WITH NOCHECK ADD CONSTRAINT [DF_Downtime_DowntimeId] DEFAULT (NEWSEQUENTIALID()) FOR DowntimeId; 75 75 76 ALTER TABLE dbo. HiveExperiment ALTER COLUMN HiveExperimentId ADD ROWGUIDCOL;77 ALTER TABLE dbo. HiveExperiment WITH NOCHECK ADD CONSTRAINT [DF_HiveExperiment_HiveExperimentId] DEFAULT (NEWSEQUENTIALID()) FOR HiveExperimentId;76 ALTER TABLE dbo.Job ALTER COLUMN JobId ADD ROWGUIDCOL; 77 ALTER TABLE dbo.Job WITH NOCHECK ADD CONSTRAINT [DF_Job_JobId] DEFAULT (NEWSEQUENTIALID()) FOR JobId; 78 78 79 79 ALTER TABLE dbo.StateLog ALTER COLUMN StateLogId ADD ROWGUIDCOL; 80 80 ALTER TABLE dbo.StateLog WITH NOCHECK ADD CONSTRAINT [DF_StateLog_StateLogId] DEFAULT (NEWSEQUENTIALID()) FOR StateLogId; 81 81 82 ALTER TABLE [dbo].[ HiveExperimentPermission] DROP CONSTRAINT [HiveExperiment_HiveExperimentPermission]83 ALTER TABLE [dbo].[ HiveExperimentPermission] WITH CHECK ADD CONSTRAINT [HiveExperiment_HiveExperimentPermission] FOREIGN KEY([HiveExperimentId])84 REFERENCES [dbo].[ HiveExperiment] ([HiveExperimentId])82 ALTER TABLE [dbo].[JobPermission] DROP CONSTRAINT [Job_JobPermission] 83 ALTER TABLE [dbo].[JobPermission] WITH CHECK ADD CONSTRAINT [Job_JobPermission] FOREIGN KEY([JobId]) 84 REFERENCES [dbo].[Job] ([JobId]) 85 85 ON UPDATE CASCADE 86 86 ON DELETE CASCADE … … 161 161 /* triggers */ 162 162 GO 163 /****** Object: Trigger [dbo].[tr_ HiveExperimentDeleteCascade] Script Date: 04/19/2011 16:31:53 ******/163 /****** Object: Trigger [dbo].[tr_JobDeleteCascade] Script Date: 04/19/2011 16:31:53 ******/ 164 164 SET ANSI_NULLS ON 165 165 GO … … 174 174 -- is not compatible with cascading deletes. 175 175 -- ============================================= 176 CREATE TRIGGER [dbo].[tr_ HiveExperimentDeleteCascade] ON [dbo].[HiveExperiment] INSTEAD OF DELETE AS176 CREATE TRIGGER [dbo].[tr_JobDeleteCascade] ON [dbo].[Job] INSTEAD OF DELETE AS 177 177 BEGIN 178 DELETE Task FROM deleted, Task WHERE deleted. HiveExperimentId = Task.HiveExperimentId179 DELETE HiveExperiment FROM deleted, HiveExperiment WHERE deleted.HiveExperimentId = HiveExperiment.HiveExperimentId178 DELETE Task FROM deleted, Task WHERE deleted.JobId = Task.JobId 179 DELETE Job FROM deleted, Job WHERE deleted.JobId = Job.JobId 180 180 END 181 181 GO … … 186 186 -- Description: Recursively deletes all child-jobs of a job when it is deleted. (Source: http://devio.wordpress.com/2008/05/23/recursive-delete-in-sql-server/) 187 187 -- ============================================= 188 CREATE TRIGGER [dbo].[tr_ JobDeleteCascade] ON [dbo].[Task] INSTEAD OF DELETE AS188 CREATE TRIGGER [dbo].[tr_TaskDeleteCascade] ON [dbo].[Task] INSTEAD OF DELETE AS 189 189 BEGIN 190 190 -- add statistics … … 197 197 FROM 198 198 deleted j, 199 HiveExperimenthe,199 Job he, 200 200 view_FirstState fs, 201 201 view_LastState ls 202 202 WHERE 203 he. HiveExperimentId = j.HiveExperimentId AND203 he.JobId = j.JobId AND 204 204 fs.TaskId = j.TaskId AND 205 205 ls.TaskId = j.TaskId -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Query Jobs.sql
r6721 r6723 16 16 ,j.[FinishWhenChildJobsFinished] 17 17 ,j.[ParentTaskId] 18 , he. HiveExperimentId18 , he.JobId 19 19 FROM 20 20 [HeuristicLab.Hive-3.3].[dbo].[Task] j 21 ,[HeuristicLab.Hive-3.3].[dbo].[ HiveExperiment] he21 ,[HeuristicLab.Hive-3.3].[dbo].[Job] he 22 22 ,[HeuristicLab.Authentication].dbo.aspnet_Users u 23 23 ,[HeuristicLab.Hive-3.3].dbo.TaskData jd 24 24 WHERE 25 j. HiveExperimentId = he.HiveExperimentId25 j.JobId = he.JobId 26 26 AND j.TaskId = jd.TaskId 27 27 AND he.OwnerUserId = u.UserId
Note: See TracChangeset
for help on using the changeset viewer.