-
-
Save mitch-b/b49dc98a691b462a0684 to your computer and use it in GitHub Desktop.
Web API OData Lab 1 Database Creation Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE [WebAPIDemo] | |
GO | |
USE [WebAPIDemo] | |
GO | |
CREATE USER [WebAPIDemoUser] FOR LOGIN [WebAPIDemoUser] WITH DEFAULT_SCHEMA=[dbo] | |
GO | |
ALTER ROLE [db_datareader] ADD MEMBER [WebAPIDemoUser] | |
GO | |
ALTER ROLE [db_datawriter] ADD MEMBER [WebAPIDemoUser] | |
GO | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
SET ANSI_PADDING ON | |
GO | |
CREATE TABLE [dbo].[Todos]( | |
[Id] [int] IDENTITY(1,1) NOT NULL, | |
[Name] [nvarchar](100) NOT NULL, | |
[Description] [nvarchar](500) NOT NULL, | |
[DueDate] [datetime] NULL, | |
[CreatedOn] [datetime] NULL, | |
[CompletedOn] [datetime] NULL, | |
[Finished] [bit] NULL, | |
[CreatedBy] [varchar](50) NULL, | |
[CompletedBy] [varchar](50) NULL, | |
CONSTRAINT [PK_Todos] 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 ANSI_PADDING OFF | |
GO | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
SET ANSI_PADDING ON | |
GO | |
CREATE TABLE [dbo].[Users]( | |
[Id] [varchar](50) NOT NULL, | |
[Name] [varchar](200) NOT NULL, | |
[Email] [varchar](200) NULL, | |
[Active] [bit] NOT NULL, | |
CONSTRAINT [PK_Users] 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 ANSI_PADDING OFF | |
GO | |
ALTER TABLE [dbo].[Todos] WITH CHECK ADD CONSTRAINT [FK_Todos_Users_CompletedBy] FOREIGN KEY([CompletedBy]) | |
REFERENCES [dbo].[Users] ([Id]) | |
GO | |
ALTER TABLE [dbo].[Todos] CHECK CONSTRAINT [FK_Todos_Users_CompletedBy] | |
GO | |
ALTER TABLE [dbo].[Todos] WITH CHECK ADD CONSTRAINT [FK_Todos_Users_CreatedBy] FOREIGN KEY([CreatedBy]) | |
REFERENCES [dbo].[Users] ([Id]) | |
GO | |
ALTER TABLE [dbo].[Todos] CHECK CONSTRAINT [FK_Todos_Users_CreatedBy] | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment