Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Database Design for Schedule Task

Author  Topic 

dewacorp.alliances

452 Posts

Posted - 2008-04-13 : 23:01:08
Hi there

I am trying to copy what is happing in "Schedule Task" on Windows and put into database design below. It's a denormalisation though.

What is the better way to handle this schenario such as DAILY, WEEKLY AND MONTHLY TASK? I did try put into normalisation by adding extra table called ScheduleDetail which holds DAYS and MONTHLY but it's more complicated.

Anyway .. I am waiting your comment or anything.


CREATE TABLE [dbo].[glb_Schedules](
[ScheduleID] [bigint] IDENTITY(1,1) NOT NULL,
[ScheduleGroupID] [bigint] NULL,
[ScheduleTypeID] [int] NULL,
[StartTime] [smalldatetime] NULL,
[EndTime] [smalldatetime] NULL,
[Length] [int] NULL,
[IsMonday] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsMonday] DEFAULT ((0)),
[IsTuesday] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsTuesday] DEFAULT ((0)),
[IsWednesday] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsWednesday] DEFAULT ((0)),
[IsThursday] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsThursday] DEFAULT ((0)),
[IsFirday] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsFirday] DEFAULT ((0)),
[IsSaturday] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsSaturday] DEFAULT ((0)),
[IsSunday] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsSunday] DEFAULT ((0)),
[IsJanuary] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsJanuary] DEFAULT ((0)),
[IsFebruary] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsFebruary] DEFAULT ((0)),
[IsMarch] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsMarch] DEFAULT ((0)),
[IsApril] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsApril] DEFAULT ((0)),
[IsMay] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsMay] DEFAULT ((0)),
[IsJune] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsJune] DEFAULT ((0)),
[IsJuly] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsJuly] DEFAULT ((0)),
[IsAugust] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsAugust] DEFAULT ((0)),
[IsSeptember] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsSeptember] DEFAULT ((0)),
[IsOctober] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsOctober] DEFAULT ((0)),
[IsNovember] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsNovember] DEFAULT ((0)),
[IsDecember] [bit] NULL CONSTRAINT [DF_glb_Schedules_IsDecember] DEFAULT ((0)),
[DateCreated] [datetime] NULL CONSTRAINT [DF_GLB_ScheduleDetails_DateCreated] DEFAULT (getdate()),
[LastDateModified] [datetime] NULL CONSTRAINT [DF_GLB_ScheduleDetails_LastDateModified] DEFAULT (getdate()),
[IsActive] [bit] NULL CONSTRAINT [DF_GLB_ScheduleDetails_IsActive] DEFAULT ((1)),
CONSTRAINT [PK_GLB_ScheduleDetails] PRIMARY KEY CLUSTERED
(
[ScheduleID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2008-04-14 : 04:01:53
Are you *really* sure you wanna go down this road? It's been tried numerous times before and the general advice every time is to stick with what's allready there...scheduled tasks in Windows or Jobs in SQL Server. If you do have to create something like this, then I'd suggest you have a look at the tables starting with sysjob* in the msdb system database.

Unless you have a pretty easy scheduling of these tasks it'll be quite a pain in the neck.

--
Lumbago
Go to Top of Page

dewacorp.alliances

452 Posts

Posted - 2008-04-20 : 04:13:42
This is not for schedule task by the way.

It's database design model that I need to adapt for my own application which has a schedule similar like this for different purpose.

Hope this help.

quote:
Originally posted by Lumbago

Are you *really* sure you wanna go down this road? It's been tried numerous times before and the general advice every time is to stick with what's allready there...scheduled tasks in Windows or Jobs in SQL Server. If you do have to create something like this, then I'd suggest you have a look at the tables starting with sysjob* in the msdb system database.

Unless you have a pretty easy scheduling of these tasks it'll be quite a pain in the neck.

--
Lumbago

Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2008-04-21 : 02:47:42
What is it you're trying to schedule, and are you creating so many schedules so that it's going to be unmanagable in SQL Server Agent? You can create sql server jobs using script you know...

And how are you going to run these jobs on time? Say you have two jobs that each take 10 minutes and one of them is supposed to start at 09:00 and the other is supposed to start at 09:05. How will you handle this?

--
Lumbago
Go to Top of Page

cjtech
Starting Member

1 Post

Posted - 2009-07-04 : 11:05:42
dewacorp.alliances,

I'm sure that by now you figured out the solution to this. I'm trying to do the same thing within an application - design the database so that certain records can have schedules tied to them. If you have any insight or sample database code I would greatly appreciate it.

Thanks---
Go to Top of Page
   

- Advertisement -