kekmodel's picture
Add files using upload-large-folder tool
4f5674d verified
raw
history blame
4.19 kB
-- Schema: bird__codebase_community
CREATE SCHEMA IF NOT EXISTS "bird__codebase_community";
-- Table: badges
CREATE TABLE "bird__codebase_community"."badges" (
"Id" BIGINT NOT NULL,
"UserId" BIGINT,
"Name" TEXT,
"Date" TIMESTAMP,
CONSTRAINT "badges_pkey" PRIMARY KEY ("Id")
);
-- Table: comments
CREATE TABLE "bird__codebase_community"."comments" (
"Id" BIGINT NOT NULL,
"PostId" BIGINT,
"Score" BIGINT,
"Text" TEXT,
"CreationDate" TIMESTAMP,
"UserId" BIGINT,
"UserDisplayName" TEXT,
CONSTRAINT "comments_pkey" PRIMARY KEY ("Id")
);
-- Table: postHistory
CREATE TABLE "bird__codebase_community"."postHistory" (
"Id" BIGINT NOT NULL,
"PostHistoryTypeId" BIGINT,
"PostId" BIGINT,
"RevisionGUID" TEXT,
"CreationDate" TIMESTAMP,
"UserId" BIGINT,
"Text" TEXT,
"Comment" TEXT,
"UserDisplayName" TEXT,
CONSTRAINT "postHistory_pkey" PRIMARY KEY ("Id")
);
-- Table: postLinks
CREATE TABLE "bird__codebase_community"."postLinks" (
"Id" BIGINT NOT NULL,
"CreationDate" TIMESTAMP,
"PostId" BIGINT,
"RelatedPostId" BIGINT,
"LinkTypeId" BIGINT,
CONSTRAINT "postLinks_pkey" PRIMARY KEY ("Id")
);
-- Table: posts
CREATE TABLE "bird__codebase_community"."posts" (
"Id" BIGINT NOT NULL,
"PostTypeId" BIGINT,
"AcceptedAnswerId" BIGINT,
"CreaionDate" TIMESTAMP,
"Score" BIGINT,
"ViewCount" BIGINT,
"Body" TEXT,
"OwnerUserId" BIGINT,
"LasActivityDate" TIMESTAMP,
"Title" TEXT,
"Tags" TEXT,
"AnswerCount" BIGINT,
"CommentCount" BIGINT,
"FavoriteCount" BIGINT,
"LastEditorUserId" BIGINT,
"LastEditDate" TIMESTAMP,
"CommunityOwnedDate" TIMESTAMP,
"ParentId" BIGINT,
"ClosedDate" TIMESTAMP,
"OwnerDisplayName" TEXT,
"LastEditorDisplayName" TEXT,
CONSTRAINT "posts_pkey" PRIMARY KEY ("Id")
);
-- Table: tags
CREATE TABLE "bird__codebase_community"."tags" (
"Id" BIGINT NOT NULL,
"TagName" TEXT,
"Count" BIGINT,
"ExcerptPostId" BIGINT,
"WikiPostId" BIGINT,
CONSTRAINT "tags_pkey" PRIMARY KEY ("Id")
);
-- Table: users
CREATE TABLE "bird__codebase_community"."users" (
"Id" BIGINT NOT NULL,
"Reputation" BIGINT,
"CreationDate" TIMESTAMP,
"DisplayName" TEXT,
"LastAccessDate" TIMESTAMP,
"WebsiteUrl" TEXT,
"Location" TEXT,
"AboutMe" TEXT,
"Views" BIGINT,
"UpVotes" BIGINT,
"DownVotes" BIGINT,
"AccountId" BIGINT,
"Age" BIGINT,
"ProfileImageUrl" TEXT,
CONSTRAINT "users_pkey" PRIMARY KEY ("Id")
);
-- Table: votes
CREATE TABLE "bird__codebase_community"."votes" (
"Id" BIGINT NOT NULL,
"PostId" BIGINT,
"VoteTypeId" BIGINT,
"CreationDate" DATE,
"UserId" BIGINT,
"BountyAmount" BIGINT,
CONSTRAINT "votes_pkey" PRIMARY KEY ("Id")
);
-- Foreign Keys
ALTER TABLE "bird__codebase_community"."badges" ADD CONSTRAINT "fk_badges_0" FOREIGN KEY ("UserId") REFERENCES "bird__codebase_community"."users" ("Id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "bird__codebase_community"."comments" ADD CONSTRAINT "fk_comments_0" FOREIGN KEY ("UserId") REFERENCES "bird__codebase_community"."users" ("Id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "bird__codebase_community"."postHistory" ADD CONSTRAINT "fk_postHistory_0" FOREIGN KEY ("UserId") REFERENCES "bird__codebase_community"."users" ("Id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "bird__codebase_community"."posts" ADD CONSTRAINT "fk_posts_1" FOREIGN KEY ("OwnerUserId") REFERENCES "bird__codebase_community"."users" ("Id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "bird__codebase_community"."posts" ADD CONSTRAINT "fk_posts_2" FOREIGN KEY ("LastEditorUserId") REFERENCES "bird__codebase_community"."users" ("Id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "bird__codebase_community"."votes" ADD CONSTRAINT "fk_votes_0" FOREIGN KEY ("UserId") REFERENCES "bird__codebase_community"."users" ("Id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "bird__codebase_community"."votes" ADD CONSTRAINT "fk_votes_1" FOREIGN KEY ("PostId") REFERENCES "bird__codebase_community"."posts" ("Id") ON DELETE CASCADE ON UPDATE CASCADE;