January 12, 2015 at 8:11 pm
Hi All,
I have a problem in Designing tables for events which are scheduling daily,weekly, monthly and yearly.
My current design for Scheduling is done for only weekly. Now i want to enhance it to Monthly and Yearly.
----------------------------------------------------------------------------------------------------------------------------
Create Table Activities
(
Id Int Primary Key Identity(1,1),
Name nvarchar(200) Not Null,
ActivityDate Date Not Null,
FromTime Time(0) Not Null,
ToTime Time(0) Not Null,
)
CREATE TABLE [dbo].[ActivitySchedules](
[Id] [int] IDENTITY(1,1) NOT NULL,
[ActivityId] [int] NOT NULL,
[ScheduleDay] [int] NOT NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON
---------------------------------------------------------------------------------------------------------------------------
Can anyone help me in this design please.
Thank you.
January 12, 2015 at 9:10 pm
vishnu.vardhan414 (1/12/2015)
Hi All,I have a problem in Designing tables for events which are scheduling daily,weekly, monthly and yearly.
My current design for Scheduling is done for only weekly. Now i want to enhance it to Monthly and Yearly.
----------------------------------------------------------------------------------------------------------------------------
Create Table Activities
(
Id Int Primary Key Identity(1,1),
Name nvarchar(200) Not Null,
ActivityDate Date Not Null,
FromTime Time(0) Not Null,
ToTime Time(0) Not Null,
)
CREATE TABLE [dbo].[ActivitySchedules](
[Id] [int] IDENTITY(1,1) NOT NULL,
[ActivityId] [int] NOT NULL,
[ScheduleDay] [int] NOT NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON
---------------------------------------------------------------------------------------------------------------------------
Can anyone help me in this design please.
Thank you.
Your current design isn't for weekly. It's for daily. It shouldn't be for either. It should be for "activity", which can certainly span more than one day. If it only occurs once, you're golden. If it occurs more than once (for weekly, monthly, or yearly), then take a lesson from the job scheduler tables in MSDB. Each activity is marked for a recurring schedule type and you can do one of two things or both, depending on your need. Either create a row for the next occurrence of the activity once the current activity is complete or preschedule many rows based on the schedule type for the activity.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 12, 2015 at 10:08 pm
Hi Jeff Moden,
Thank you for your response. I will take your points into consideration and examine those.
Thank you
January 13, 2015 at 1:34 am
You bet, Vishnu. Thank you for the feedback.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply