-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.sql
226 lines (185 loc) · 5.21 KB
/
db.sql
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
-- phpMyAdmin SQL Dump
-- version 4.2.7
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Nov 12, 2014 at 02:31 AM
-- Server version: 5.5.38-log
-- PHP Version: 5.4.31
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Database: `pregmatch`
--
-- --------------------------------------------------------
--
-- Table structure for table `Comment`
--
CREATE TABLE IF NOT EXISTS `Comment` (
`Id` int(11) NOT NULL,
`Comment` varchar(128) NOT NULL,
`Post` int(11) NOT NULL,
`Nick` varchar(45) DEFAULT NULL,
`Email` varchar(45) DEFAULT NULL,
`DateCreated` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `Comment`
--
-- --------------------------------------------------------
--
-- Table structure for table `Post`
--
CREATE TABLE IF NOT EXISTS `Post` (
`Id` int(11) NOT NULL,
`Title` varchar(128) NOT NULL,
`DateCreated` datetime NOT NULL,
`DateModified` varchar(6) DEFAULT NULL,
`Content` text NOT NULL,
`Photo` varchar(45) NOT NULL,
`User` int(11) NOT NULL,
`Slug` varchar(45) NOT NULL,
`NoOfViews` int(11) NOT NULL,
`PostStatus` enum('0','1') NOT NULL,
`Password` varchar(128) DEFAULT 'NULL'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
--
-- Dumping data for table `Post`
--
-- --------------------------------------------------------
--
-- Table structure for table `PostTag`
--
CREATE TABLE IF NOT EXISTS `PostTag` (
`Tag` int(11) NOT NULL,
`Post` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `PostTag`
--
-- --------------------------------------------------------
--
-- Table structure for table `Tag`
--
CREATE TABLE IF NOT EXISTS `Tag` (
`Id` int(11) NOT NULL,
`TagName` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=21 ;
--
-- Dumping data for table `Tag`
--
-- --------------------------------------------------------
--
-- Table structure for table `User`
--
CREATE TABLE IF NOT EXISTS `User` (
`Id` int(11) NOT NULL,
`Nick` varchar(45) NOT NULL,
`Email` varchar(45) NOT NULL,
`Role` varchar(6) NOT NULL,
`Password` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;
--
-- Dumping data for table `User`
--
INSERT INTO `User` (`Id`, `Nick`, `Email`, `Role`, `Password`) VALUES
(7, 'Admin', 'admin@blog.com', 'Admin', 'pbkdf2:sha1:1000$RdRBS3jZ$42a1e2046eb318a6fba8dd8b8708b0be40bc464d');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `Comment`
--
ALTER TABLE `Comment`
ADD PRIMARY KEY (`Id`), ADD KEY `Post_idx` (`Post`);
--
-- Indexes for table `Post`
--
ALTER TABLE `Post`
ADD PRIMARY KEY (`Id`), ADD KEY `User_idx` (`User`);
--
-- Indexes for table `PostTag`
--
ALTER TABLE `PostTag`
ADD PRIMARY KEY (`Tag`,`Post`), ADD KEY `fk_Tags_has_Post_Post1_idx` (`Post`), ADD KEY `fk_Tags_has_Post_Tags1_idx` (`Tag`);
--
-- Indexes for table `Tag`
--
ALTER TABLE `Tag`
ADD PRIMARY KEY (`Id`);
--
-- Indexes for table `User`
--
ALTER TABLE `User`
ADD PRIMARY KEY (`Id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `Comment`
--
ALTER TABLE `Comment`
MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `Post`
--
ALTER TABLE `Post`
MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `Tag`
--
ALTER TABLE `Tag`
MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=21;
--
-- AUTO_INCREMENT for table `User`
--
ALTER TABLE `User`
MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=9;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `Comment`
--
ALTER TABLE `Comment`
ADD CONSTRAINT `Post` FOREIGN KEY (`Post`) REFERENCES `Post` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `Post`
--
ALTER TABLE `Post`
ADD CONSTRAINT `User` FOREIGN KEY (`User`) REFERENCES `User` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE `Post`
ADD PRIMARY KEY (`Id`), ADD KEY `User_idx` (`User`), ADD KEY `Password` (`Password`);
--
-- Constraints for table `PostTag`
--
ALTER TABLE `PostTag`
ADD CONSTRAINT `fk_Tags_has_Post_Post1` FOREIGN KEY (`Post`) REFERENCES `Post` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_Tags_has_Post_Tags1` FOREIGN KEY (`Tag`) REFERENCES `Tag` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
CREATE TABLE IF NOT EXISTS `pregmatch`.`PostFile` (
`Id` INT NOT NULL AUTO_INCREMENT,
`Post` INT NULL,
`FileName` VARCHAR(128) NULL,
PRIMARY KEY (`Id`),
INDEX `Post_idx` (`Post` ASC),
CONSTRAINT `Post_fk`
FOREIGN KEY (`Post`)
REFERENCES `pregmatch`.`Post` (`Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
CREATE TABLE IF NOT EXISTS `pregmatch`.`PostImage` (
`Id` INT NOT NULL AUTO_INCREMENT,
`ImageName` VARCHAR(128) NULL,
`Post` INT NULL,
PRIMARY KEY (`Id`),
INDEX `Post_idx` (`Post` ASC),
CONSTRAINT `Post_fk_i`
FOREIGN KEY (`Post`)
REFERENCES `pregmatch`.`Post` (`Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
ALTER table Comment add `Parent` int(11) DEFAULT NULL;
ALTER TABLE `Comment` ADD KEY `Parent` (`Parent`);
ALTER TABLE `Comment` ADD CONSTRAINT `comment_ibfk_1` FOREIGN KEY (`Parent`) REFERENCES `Comment` (`Id`);