Created
December 18, 2014 05:36
-
-
Save AlexArchive/5a766530aba28ca193d8 to your computer and use it in GitHub Desktop.
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
USE [Medium] | |
GO | |
DELETE FROM [Post_Tag_Junction] | |
DELETE FROM [Posts] | |
DELETE FROM [Tags] | |
INSERT INTO [Tags] | |
VALUES | |
('Angular'), | |
('React') | |
INSERT INTO [Posts] | |
VALUES ( | |
'angular-one-time-binding-syntax', | |
'Angular one-time binding syntax', | |
'Angular 1.3 shipped with an awesome new performance enhancing feature - one-time binding.', | |
1, | |
GETDATE()) | |
INSERT INTO [Post_Tag_Junction] | |
VALUES | |
('angular-one-time-binding-syntax', 'Angular'), | |
('angular-one-time-binding-syntax', 'React') | |
SELECT * | |
FROM [Posts] | |
WHERE [Slug] = 'angular-one-time-binding-syntax' | |
SELECT [TagName] | |
FROM [Post_Tag_Junction] | |
WHERE [PostSlug] = 'angular-one-time-binding-syntax' |
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 [Medium] | |
GO | |
USE [Medium] | |
GO | |
CREATE TABLE [Posts] ( | |
[Id] INT IDENTITY PRIMARY KEY, | |
[Slug] NVARCHAR(250) NOT NULL UNIQUE, | |
[Title] NVARCHAR(200) NOT NULL, | |
[Body] NVARCHAR(MAX) NOT NULL, | |
[Published] BIT NOT NULL, | |
[PublishedAt] DATETIME NOT NULL, | |
) | |
GO | |
CREATE TABLE [Tags] ( | |
[Name] NVARCHAR(250) PRIMARY KEY NOT NULL | |
) | |
GO | |
CREATE TABLE [Post_Tag_Junction] ( | |
[PostSlug] NVARCHAR(250), | |
[TagName] NVARCHAR(250) | |
CONSTRAINT [Key] PRIMARY KEY ([PostSlug], [TagName]), | |
CONSTRAINT [Fk_Post] | |
FOREIGN KEY ([PostSlug]) REFERENCES [Posts] ([Slug]), | |
CONSTRAINT [Fk_Slug] | |
FOREIGN KEY ([TagName]) REFERENCES [Tags] ([Name]) | |
) | |
GO | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment