Microsoft SQL Server

  • 2 minutes to read

The following *.sql script can be used to generate two tables to persist appointment and resource data.


CREATE TABLE [dbo].[Appointments] (
        [UniqueID] [int] IDENTITY (1, 1) NOT NULL,
        [Type] [int] NULL,
        [StartDate] [datetime] NULL,
        [EndDate] [datetime] NULL,
        [QueryStartDate] [datetime] NULL,
        [QueryEndDate] [datetime] NULL,
        [AllDay] [bit] NULL,
        [Subject] [nvarchar] (50) NULL,
        [Location] [nvarchar] (50) NULL,
        [Description] [nvarchar](max) NULL,
        [Status] [int] NULL,
        [Label] [int] NULL,
        [ResourceID] [int] NULL,
        [ResourceIDs] [nvarchar](max) NULL,
        [ReminderInfo] [nvarchar](max) NULL,
        [RecurrenceInfo] [nvarchar](max) NULL,
        [TimeZoneId] [nvarchar](max) NULL,
        [CustomField1] [nvarchar](max) NULL 
CONSTRAINT [PK_Appointments] PRIMARY KEY CLUSTERED
(
        [UniqueID] ASC
)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE TABLE [dbo].[Resources] (
        [UniqueID] [int] IDENTITY (1, 1) NOT NULL,
        [ResourceID] [int] NOT NULL,
        [ResourceName] [nvarchar] (50) NULL,
        [Color] [int] NULL,
        [Image] [image] NULL,
        [CustomField1] [nvarchar](max) NULL 
CONSTRAINT [PK_Resources] PRIMARY KEY CLUSTERED
(
        [UniqueID] ASC
)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET IDENTITY_INSERT [dbo].[Resources] ON
INSERT [dbo].[Resources] ([UniqueID], [ResourceID], [ResourceName], [Color], [Image], [CustomField1]) VALUES (1, 1, N'Resource One', NULL, NULL, NULL)
INSERT [dbo].[Resources] ([UniqueID], [ResourceID], [ResourceName], [Color], [Image], [CustomField1]) VALUES (2, 2, N'Resource Two', NULL, NULL, NULL)
INSERT [dbo].[Resources] ([UniqueID], [ResourceID], [ResourceName], [Color], [Image], [CustomField1]) VALUES (3, 3, N'Resource Three', NULL, NULL, NULL)
SET IDENTITY_INSERT [dbo].[Resources] OFF

GO
NOTE

If SchedulerControl.ResourceSharing is enabled, map the Appointments.ResourceID property to the ResourceIDs field which is [nvarchar](max); otherwise map it to the ResourceID field. The ResourceID does not necessarily need to be an integer; the Scheduler treats resource identifier it as if it is of an Object type, so you can use any type supported by MS SQL Server. Starting from version 15.2, resource identifiers are serialized in Base64 format. To revert to the previous storage format, set the SchedulerCompatibility.Base64XmlObjectSerialization property to false. Make sure that the type of the ResourceID field is the same in Appointments and Resources tables.

TIP

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E551.

These tables are sufficient for basic scheduling tasks. To learn how to implement a special functionality, such as Gantt view or resources hierarchy, see the Hierarchical Resource Specifics and the Gantt View Specifics topics.