Created
August 27, 2012 12:49
-
-
Save Allon-Guralnek/3488126 to your computer and use it in GitHub Desktop.
Create tables and data for test database 'Wiki' (for http://stackoverflow.com/questions/12138353/)
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
IF OBJECT_ID('Articles', 'U') IS NOT NULL DROP TABLE Articles | |
IF OBJECT_ID('Authors', 'U') IS NOT NULL DROP TABLE Authors | |
CREATE TABLE Authors | |
( | |
ID INT NOT NULL IDENTITY, | |
Name NVARCHAR(100) NOT NULL, | |
CONSTRAINT PK_Authors PRIMARY KEY CLUSTERED (ID) | |
) | |
CREATE TABLE Articles | |
( | |
AuthorID INT NOT NULL REFERENCES Authors(ID), | |
Title NVARCHAR(100) NOT NULL, | |
Revision INT NOT NULL, | |
CreatedUTC DATETIME2(2) NOT NULL DEFAULT GETUTCDATE(), | |
Body NVARCHAR(500), | |
CONSTRAINT PK_Articles PRIMARY KEY CLUSTERED (AuthorID, Title, Revision) | |
) | |
INSERT INTO Authors (Name) VALUES ('John Doe') | |
INSERT INTO Articles (AuthorID, Title, Revision, Body) VALUES | |
(1, 'Article A', 1, 'A-1'), | |
(1, 'Article A', 2, 'A-2'), | |
(1, 'Article B', 1, 'B-1') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment