File size: 4,193 Bytes
4f5674d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
-- 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;