-
Notifications
You must be signed in to change notification settings - Fork 13
/
madison.sql
230 lines (188 loc) · 6.24 KB
/
madison.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
-- phpMyAdmin SQL Dump
-- version 4.0.0-dev
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Feb 14, 2013 at 02:07 PM
-- Server version: 5.5.25a
-- PHP Version: 5.3.15
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: `madison`
--
-- --------------------------------------------------------
--
-- Table structure for table `bills`
--
CREATE TABLE IF NOT EXISTS `bills` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`bill` varchar(255) NOT NULL,
`shortname` varchar(64) DEFAULT NULL,
`slug` varchar(255) NOT NULL,
`description` text,
`twitter_text` varchar(160) DEFAULT NULL,
`twitter_hash` varchar(160) DEFAULT NULL,
`doc_location` varchar(255) DEFAULT NULL,
`init_section` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `bill_content`
--
CREATE TABLE IF NOT EXISTS `bill_content` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`bill_id` int(11) NOT NULL,
`parent` int(11) NOT NULL,
`child_priority` int(11) DEFAULT '0',
`content` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Stand-in structure for view `comments_dump`
--
CREATE TABLE IF NOT EXISTS `comments_dump` (
`user` int(11)
,`comments` bigint(21)
,`email` varchar(128)
);
-- --------------------------------------------------------
--
-- Table structure for table `emails`
--
CREATE TABLE IF NOT EXISTS `emails` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(128) NOT NULL,
`bill` varchar(4) NOT NULL,
`last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `notes`
--
CREATE TABLE IF NOT EXISTS `notes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` int(11) NOT NULL,
`bill_id` int(11) NOT NULL,
`part_id` int(11) NOT NULL,
`parent` int(11) NOT NULL DEFAULT '0',
`type` set('suggestion','comment') NOT NULL,
`note` text NOT NULL,
`likes` int(11) NOT NULL DEFAULT '0',
`dislikes` int(11) NOT NULL DEFAULT '0',
`flags` int(11) NOT NULL DEFAULT '0',
`time_stamp` bigint(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `note_meta`
--
CREATE TABLE IF NOT EXISTS `note_meta` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`note_id` int(11) NOT NULL,
`meta_key` varchar(128) NOT NULL,
`meta_value` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `site_info`
--
CREATE TABLE IF NOT EXISTS `site_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`meta_key` varchar(128) NOT NULL,
`meta_value` text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `meta_key` (`meta_key`),
KEY `meta_key_2` (`meta_key`),
KEY `meta_key_3` (`meta_key`),
KEY `meta_key_4` (`meta_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `top_comments`
--
CREATE TABLE IF NOT EXISTS `top_comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`comment_id` int(11) DEFAULT NULL,
`likes` int(11) DEFAULT NULL,
`dislikes` int(11) DEFAULT NULL,
`flags` int(11) DEFAULT NULL,
`score` float DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `score` (`score`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `top_notes`
--
CREATE TABLE IF NOT EXISTS `top_notes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`bill_id` int(11) NOT NULL,
`note_id` int(11) DEFAULT NULL,
`score` float DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `score` (`score`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `top_suggestions`
--
CREATE TABLE IF NOT EXISTS `top_suggestions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`suggestion_id` int(11) DEFAULT NULL,
`likes` int(11) DEFAULT NULL,
`dislikes` int(11) DEFAULT NULL,
`flags` int(11) DEFAULT NULL,
`score` float DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `score` (`score`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(128) NOT NULL,
`password` varchar(128) NOT NULL,
`fname` varchar(64) NOT NULL,
`lname` varchar(64) NOT NULL,
`company` varchar(128) NOT NULL,
`zip` varchar(16) NOT NULL,
`phone` varchar(64) NOT NULL,
`position` varchar(128) NOT NULL,
`url` varchar(128) NOT NULL,
`user_level` int(11) NOT NULL DEFAULT '3',
`last_login` bigint(20) NOT NULL,
`created` bigint(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `user_meta`
--
CREATE TABLE IF NOT EXISTS `user_meta` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` int(11) NOT NULL,
`meta_key` varchar(128) NOT NULL,
`meta_value` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Structure for view `comments_dump`
--
DROP TABLE IF EXISTS `comments_dump`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `comments_dump` AS select `notes`.`user` AS `user`,count(0) AS `comments`,`users`.`email` AS `email` from (`notes` join `users`) where (`users`.`id` = `notes`.`user`) group by `notes`.`user` order by count(0) desc;
/*!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 */;