Skip to content

Instantly share code, notes, and snippets.

@blaiseAI
Created April 15, 2021 03:44
Show Gist options
  • Save blaiseAI/705b84e2bfdb14409ec0aee223f15176 to your computer and use it in GitHub Desktop.
Save blaiseAI/705b84e2bfdb14409ec0aee223f15176 to your computer and use it in GitHub Desktop.
DML Starter
CREATE TABLE Blogs (
BlogId INT IDENTITY (1, 1) NOT NULL,
Name NVARCHAR (200) NULL,
Url NVARCHAR (200) NULL,
CONSTRAINT [PK_dbo.Blogs] PRIMARY KEY CLUSTERED ([BlogId] ASC)
);
CREATE TABLE Posts (
PostId INT IDENTITY (1, 1) NOT NULL,
Title NVARCHAR (200) NULL,
Content NTEXT NULL,
BlogId INT NOT NULL,
CONSTRAINT [PK_dbo.Posts] PRIMARY KEY CLUSTERED (PostId ASC),
CONSTRAINT [FK_dbo.Posts_dbo.Blogs_BlogId] FOREIGN KEY ([BlogId]) REFERENCES [dbo].[Blogs] ([BlogId]) ON DELETE CASCADE
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment