New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Database Structure

The Gantt's data can be stored within a Database with tables for the Tasks and Dependencies. Below is shown a sample database with all required fields.

Tasksgantt-database-structure-1

You can use the following script to add the Gantt's Tasks table to an existing database:

USE [DBNAME]
GO

--CREATE TASKS TABLE
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GanttTasks](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [ParentID] [int] NULL,
    [OrderID] [int] NOT NULL,
    [Title] [ntext] NULL,
    [Start] [datetime] NOT NULL,
    [End] [datetime] NOT NULL,
    [PercentComplete] [decimal](5, 2) NOT NULL,
    [Expanded] [bit] NULL,
    [Summary] [bit] NOT NULL,
 CONSTRAINT [PK_GanttTasks] 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 [PRIMARY] TEXTIMAGE_ON [PRIMARY]

SET IDENTITY_INSERT [dbo].[GanttTasks] OFF
ALTER TABLE [dbo].[GanttTasks] ADD  CONSTRAINT [DF_GanttTasks_Summary]  DEFAULT ((0)) FOR [Summary]
GO
ALTER TABLE [dbo].[GanttTasks]  WITH CHECK ADD  CONSTRAINT [FK_GanttTasks_GanttTasks] FOREIGN KEY([ParentID])
REFERENCES [dbo].[GanttTasks] ([ID])
GO
ALTER TABLE [dbo].[GanttTasks] CHECK CONSTRAINT [FK_GanttTasks_GanttTasks]
GO

Planned/Baseline Tasks

R2 2021 introduces the Planned vs Actual/Baseline functionality. To leverage it, the PlannedStart and PlannedEnd columns should be added. They should be nullable and of type datetime.

USE [DBNAME]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[GanttPlannedTasks](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [ParentID] [int] NULL,
    [OrderID] [int] NOT NULL,
    [Title] [ntext] NULL,
    [Start] [datetime] NOT NULL,
    [PlannedStart] [datetime] NULL,
    [End] [datetime] NOT NULL,
    [PlannedEnd] [datetime] NULL,
    [PercentComplete] [decimal](5, 2) NOT NULL,
    [Expanded] [bit] NULL,
    [Summary] [bit] NOT NULL,
 CONSTRAINT [PK_GanttPlannedTasks] 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 [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

ALTER TABLE [dbo].[GanttPlannedTasks]  WITH CHECK ADD  CONSTRAINT [FK_GanttPlannedTasks_GanttPlannedTasks] FOREIGN KEY([ParentID])
REFERENCES [dbo].[GanttPlannedTasks] ([ID])
GO

ALTER TABLE [dbo].[GanttPlannedTasks] CHECK CONSTRAINT [FK_GanttPlannedTasks_GanttPlannedTasks]
GO

Dependenciesgantt-database-structure-2

Here is a simpler example without support for resources:

--CREATE DEPENDENCIES TABLE
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GanttDependencies](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [PredecessorID] [int] NOT NULL,
    [SuccessorID] [int] NOT NULL,
    [Type] [int] NOT NULL,
 CONSTRAINT [PK_GanttDependencies] 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 [PRIMARY]

GO
SET IDENTITY_INSERT [dbo].[GanttDependencies] ON 

See Also

In this article