Create a Sample SQL Database for Scheduler Appointments and Resources
- 3 minutes to read
Use the following *.sql script to generate appointment and resource data tables for Microsoft SQL Server.
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
SQLite uses slightly different data type names (see Datatypes In SQLite). For this SQL database engine, the “CREATE” queries should look like the following:
CREATE TABLE Appointments (
UniqueID INTEGER PRIMARY KEY AUTOINCREMENT,
Type INTEGER NULL,
StartDate TEXT NULL,
EndDate TEXT NULL,
AllDay INTEGER NULL,
Subject TEXT NULL,
Location TEXT NULL,
Description TEXT NULL,
Status INTEGER NULL,
Label INTEGER NULL,
ResourceID INTEGER NULL,
ReminderInfo TEXT NULL,
RecurrenceInfo TEXT NULL,
OriginalOccurrenceStart TEXT NULL,
OriginalOccurrenceEnd TEXT NULL,
TimeZoneId TEXT NULL,
CustomField1 TEXT NULL
);
CREATE TABLE Resources (
UniqueID INTEGER PRIMARY KEY AUTOINCREMENT,
ResourceID INTEGER NOT NULL,
ParentId INTEGER NULL,
ResourceName TEXT NULL,
Color INTEGER NULL
);
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 https://supportcenter.devexpress.com/ticket/details/e551/winforms-scheduler-bind-to-ms-sql-server-runtime.
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.