-
Notifications
You must be signed in to change notification settings - Fork 0
/
gurugyaan.sql
265 lines (215 loc) · 7.28 KB
/
gurugyaan.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
-- phpMyAdmin SQL Dump
-- version 4.3.11
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jan 13, 2018 at 08:52 AM
-- Server version: 5.6.24
-- PHP Version: 5.6.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `gurugyaan`
--
-- --------------------------------------------------------
--
-- Table structure for table `answers`
--
CREATE TABLE IF NOT EXISTS `answers` (
`a_id` int(50) unsigned NOT NULL,
`q_id` int(50) unsigned DEFAULT NULL,
`answer_by` varchar(10) DEFAULT NULL,
`answer` varchar(1000) DEFAULT NULL,
`add_date` varchar(10) DEFAULT NULL,
`add_time` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `a_likes`
--
CREATE TABLE IF NOT EXISTS `a_likes` (
`ans_id` int(50) unsigned DEFAULT NULL,
`stu_mbl` varchar(10) DEFAULT NULL,
`likes` int(50) DEFAULT NULL,
`dislikes` int(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `category`
--
CREATE TABLE IF NOT EXISTS `category` (
`c_id` int(50) unsigned NOT NULL,
`value` varchar(50) DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `category`
--
INSERT INTO `category` (`c_id`, `value`) VALUES
(1, 'Technology'),
(2, 'Fashion'),
(3, 'Literature');
-- --------------------------------------------------------
--
-- Table structure for table `expert`
--
CREATE TABLE IF NOT EXISTS `expert` (
`fname` varchar(30) DEFAULT NULL,
`lname` varchar(30) DEFAULT NULL,
`mbl` varchar(10) NOT NULL DEFAULT '',
`email` varchar(100) DEFAULT NULL,
`psw` varchar(200) DEFAULT NULL,
`add_date` varchar(10) DEFAULT NULL,
`add_time` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `expert`
--
INSERT INTO `expert` (`fname`, `lname`, `mbl`, `email`, `psw`, `add_date`, `add_time`) VALUES
('Rohan', 'Mehra', '8888888888', '[email protected]', 'rohan', '2017-02-05', '01:16:51am'),
('Arun', 'Khanna', '9999999999', '[email protected]', 'hello', '2017-02-04', '03:20:39pm');
-- --------------------------------------------------------
--
-- Table structure for table `ques`
--
CREATE TABLE IF NOT EXISTS `ques` (
`q_id` int(50) unsigned NOT NULL,
`ask_by` varchar(10) DEFAULT NULL,
`ques` varchar(500) DEFAULT NULL,
`category` int(50) unsigned DEFAULT NULL,
`add_date` varchar(10) DEFAULT NULL,
`add_time` varchar(10) DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `ques`
--
INSERT INTO `ques` (`q_id`, `ask_by`, `ques`, `category`, `add_date`, `add_time`) VALUES
(2, '9983751677', 'What is the difference between android and ios?', 1, '2017-02-05', '01:11:50am'),
(3, '9983751677', 'Firebase or MySQL?', 1, '2017-02-05', '01:12:14am'),
(4, '9983751677', 'Which laptop to buy in 2017?', 1, '2017-02-05', '01:34:05am'),
(5, '9983751677', 'What is nano technology?', 1, '2017-02-05', '01:35:40am'),
(6, '9983751677', 'How to make?', 1, '2017-02-05', '01:35:54am');
-- --------------------------------------------------------
--
-- Table structure for table `q_likes`
--
CREATE TABLE IF NOT EXISTS `q_likes` (
`ques_id` int(50) unsigned DEFAULT NULL,
`exp_mbl` varchar(10) DEFAULT NULL,
`likes` int(50) unsigned DEFAULT NULL,
`dislikes` int(50) unsigned DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `q_likes`
--
INSERT INTO `q_likes` (`ques_id`, `exp_mbl`, `likes`, `dislikes`) VALUES
(2, '9999999999', 1, 0),
(2, '8888888888', 1, 0);
-- --------------------------------------------------------
--
-- Table structure for table `student`
--
CREATE TABLE IF NOT EXISTS `student` (
`fname` varchar(30) DEFAULT NULL,
`lname` varchar(30) DEFAULT NULL,
`mbl` varchar(10) NOT NULL DEFAULT '',
`email` varchar(100) DEFAULT NULL,
`psw` varchar(200) DEFAULT NULL,
`add_date` varchar(10) DEFAULT NULL,
`add_time` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `student`
--
INSERT INTO `student` (`fname`, `lname`, `mbl`, `email`, `psw`, `add_date`, `add_time`) VALUES
('Himanshu', 'Kumawat', '9983751677', '[email protected]', '013himanshu', '2017-02-04', '03:10:37pm'),
('Arun', 'Khanna', '9999999999', '[email protected]', 'arunkhanna', '2017-02-04', '03:19:56pm');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `answers`
--
ALTER TABLE `answers`
ADD PRIMARY KEY (`a_id`), ADD KEY `answer_by` (`answer_by`), ADD KEY `q_id` (`q_id`);
--
-- Indexes for table `a_likes`
--
ALTER TABLE `a_likes`
ADD KEY `ans_id` (`ans_id`), ADD KEY `stu_mbl` (`stu_mbl`);
--
-- Indexes for table `category`
--
ALTER TABLE `category`
ADD PRIMARY KEY (`c_id`);
--
-- Indexes for table `expert`
--
ALTER TABLE `expert`
ADD PRIMARY KEY (`mbl`);
--
-- Indexes for table `ques`
--
ALTER TABLE `ques`
ADD PRIMARY KEY (`q_id`), ADD KEY `ask_by` (`ask_by`), ADD KEY `category` (`category`);
--
-- Indexes for table `q_likes`
--
ALTER TABLE `q_likes`
ADD KEY `ques_id` (`ques_id`), ADD KEY `exp_mbl` (`exp_mbl`);
--
-- Indexes for table `student`
--
ALTER TABLE `student`
ADD PRIMARY KEY (`mbl`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `answers`
--
ALTER TABLE `answers`
MODIFY `a_id` int(50) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
MODIFY `c_id` int(50) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `ques`
--
ALTER TABLE `ques`
MODIFY `q_id` int(50) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=7;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `answers`
--
ALTER TABLE `answers`
ADD CONSTRAINT `answers_ibfk_1` FOREIGN KEY (`answer_by`) REFERENCES `expert` (`mbl`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `answers_ibfk_2` FOREIGN KEY (`q_id`) REFERENCES `ques` (`q_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `a_likes`
--
ALTER TABLE `a_likes`
ADD CONSTRAINT `a_likes_ibfk_1` FOREIGN KEY (`ans_id`) REFERENCES `answers` (`a_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `a_likes_ibfk_2` FOREIGN KEY (`stu_mbl`) REFERENCES `student` (`mbl`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `ques`
--
ALTER TABLE `ques`
ADD CONSTRAINT `ques_ibfk_1` FOREIGN KEY (`ask_by`) REFERENCES `student` (`mbl`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `ques_ibfk_2` FOREIGN KEY (`category`) REFERENCES `category` (`c_id`) ON DELETE SET NULL ON UPDATE SET NULL;
--
-- Constraints for table `q_likes`
--
ALTER TABLE `q_likes`
ADD CONSTRAINT `q_likes_ibfk_1` FOREIGN KEY (`ques_id`) REFERENCES `ques` (`q_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `q_likes_ibfk_2` FOREIGN KEY (`exp_mbl`) REFERENCES `expert` (`mbl`) ON DELETE CASCADE ON UPDATE CASCADE;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;