BDG Scenario 3

Activity.sql

If Exists (Select * From sysobjects Where name = N'Activity' And user_name(uid) = N'dbo')
    Drop Table dbo.Activity
Go

Create Table dbo.Activity
    (
    ActivityId int Not Null Identity (1, 1),
    ActivityTypeId int Not Null,
    GroupId int Not Null,
    GradeScaleId int Null,
    LocationId int Null,
    Description nvarchar(128) Not Null,
    Weight tinyint Not Null Constraint DF_Activity_Weight Default (1),
    DueDate datetime Null,
    MaxScore smallint Not Null Constraint DF_Activity_MaxPoints Default (100),
    Average float(53) Null,
    StandardDeviation float(53) Null,
    Comment ntext Null
    )
Go
Alter Table dbo.Activity Add Constraint
    PK_Activity Primary Key Nonclustered
    (
    ActivityId
    )
Go
Alter Table dbo.Activity Add Constraint
    FK_Activity_GradeScale Foreign Key
    (
    GradeScaleId
    ) References dbo.GradeScale
    (
    GradeScaleId
    )
Go
Alter Table dbo.Activity Add Constraint
    FK_Activity_ActivityType Foreign Key
    (
    ActivityTypeId
    ) References dbo.ActivityType
    (
    ActivityTypeId
    )
Go
Alter Table dbo.Activity Add Constraint
    FK_Activity_Group Foreign Key
    (
    GroupId
    ) References dbo.[Group]
    (
    GroupId
    )
Go
Alter Table dbo.Activity Add Constraint
    FK_Activity_Location Foreign Key
    (
    LocationId
    ) References dbo.Location
    (
    LocationId
    )
Go