annotate database/schema/classify.sql @ 36:baf976e34f16

regen pdf now that my tex is working again
author David A. Holland
date Sun, 15 Jun 2014 17:13:39 -0400
parents cd36b49f4437
children 40f64a96481f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
1 --
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
2 -- Classification.
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
3 --
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
4 --
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
5 -- Sorting and classifying bug reports usefully is a nontrivial
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
6 -- problem. For this reason, rather than bake in any particular
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
7 -- taxonomy, we allow multiple arbitrary classification schemes,
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
8 -- all of which are created equal. (Administratively, some will
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
9 -- be more equal than others, but that does not concern the
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
10 -- database.)
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
11 --
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
12 -- There are several classification schemes/taxonomies that already
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
13 -- exist or have been invented but not yet deployed. These fall into
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
14 -- the following categories:
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
15 --
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
16 -- 1. Hierarchical taxonomy. The only existing hierarchical taxonomy
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
17 -- is the one dholland uses in the out-of-GNATS PR lists, which
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
18 -- classifies PRs by location in the system. A second projected one is
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
19 -- classification by consequences (crashes, hangs, etc.) The possible
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
20 -- classifications are defined in advance and stored in the database.
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
21 --
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
22 -- 2. Flat taxonomy, that is, a selection from an enumeration of
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
23 -- values. Existing schemes of this type include:
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
24 --
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
25 -- * the old GNATS scheme of categories (bin, kern, lib, etc.)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
26 -- * the old GNATS scheme of classes (sw-bug, doc-bug, etc.)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
27 -- * the old GNATS severity field (critical, serious, non-critical)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
28 -- * the old GNATS priority field (high, medium, low)
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
29 --
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
30 -- For these the possible values are defined in advance and stored in
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
31 -- the database.
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
32 --
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
33 -- 3. String value. Most of the time this is really a flat taxonomy
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
34 -- where the number of possible values is large or changes dynamically
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
35 -- with external circumstances, or both, such that storing a copy of
23
ca4679ac4e02 typo in comment
David A. Holland
parents: 11
diff changeset
36 -- the legal values in the database would create a maintenance hassle.
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
37 -- There are none of these at present; the only projected one at the
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
38 -- moment is FreeBSD's idea of "the nearest man page to where the
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
39 -- problem appears to be".
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
40 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
41 -- 4. Systems of tags, that is, zero or more selections from a list
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
42 -- of possible values. Current schemes of this type include the
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
43 -- [456]-ONLY tags, the 6-CRITICAL/6-IMPORTANT/etc. release branch
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
44 -- tags, the STUCK tag, EASY, PATCH, PULLUPS-NEEDED, etc. Some of
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
45 -- these should be separate flat taxonomy schemes rather than tags,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
46 -- and some of them should maybe be states rather than tags too.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
47 -- (And, perhaps some of the current states should be tags...)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
48 -- In addition we want to allow every developer to have their own
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
49 -- private tags that aren't exposed. And, we might want to have
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
50 -- project-only tags that other developers can see but users can't.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
51 -- (It remains to be seen if that's really a good idea.)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
52 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
53 -- Note also that a list of PRs is equivalent to a tag on those PRs.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
54 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
55 -- It is also possible that there may be additional classifications
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
56 -- (possibly of any of the above types, but most likely tags) that are
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
57 -- views rather than data, that is, derived from other information.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
58 -- One example of this is "PRs in feedback more than 6 months".
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
59 --
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
60 --
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
61 -- We assume that new classification schemes will be added on the fly,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
62 -- not frequently, but frequently enough that the list of schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
63 -- should not be hard-coded into programs that access the database,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
64 -- and we don't want to have to create a new table for each new scheme
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
65 -- either.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
66 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
67 -- Therefore, the way I'll do this is to create one table (or rather,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
68 -- one family of tables) for each type of classification scheme, and
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
69 -- make them able to handle arbitrary instances.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
70 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
71 -- For hierarchical schemes there is no point trying to encode the
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
72 -- hierarchical structure in SQL; that is a waste of time. Instead
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
73 -- we'll expand the tree of allowed values and rely on the access
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
74 -- software to present the schemes sensibly.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
75 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
76 -- It remains unclear what views ought to be defined.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
77 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
78 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
79 -- Notes on the representations:
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
80 -- * a scheme is "total" if it should be defined on all PRs
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
81 -- * if the data contains a null value for a particular scheme,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
82 -- that means "not specified yet".
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
83 -- * the hierarchical and flat schemes are no different schema-
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
84 -- wise but are separate to allow different handling in software.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
85 -- * the ordering field in the values tables should be used so that
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
86 -- ORDER BY ordering ASCENDING produces the desired output order
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
87 -- of the legal values.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
88 -- * the obsolete field for values is for entries that are allowed
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
89 -- to still exist in the database but that should not be used
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
90 -- with new PRs or for new classifications of old PRs.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
91 -- * the ordering field for the classifications themselves should
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
92 -- be used so that ORDER BY ordering ASCENDING produces the
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
93 -- desired output order of the classification schemes. The
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
94 -- numbers are global across classification scheme types so
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
95 -- schemes of the same type do not need to be sorted together.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
96 --
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
97 --
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
98
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
99 ------------------------------------------------------------
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
100 -- Hierarchical schemes.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
101
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
102 -- names and properties of the hierarchical schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
103 CREATE TABLE hierclass_names (
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
104 name text primary key,
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
105 ordering int not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
106 total boolean not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
107 description text not null
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
108 )
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
109 WITHOUT OIDS;
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
110
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
111 -- allowed values of the hierarchical schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
112 CREATE TABLE hierclass_values (
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
113 scheme text not null references hierclass_names (name),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
114 value text not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
115 ordering int not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
116 obsolete boolean not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
117 description text not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
118 primary key (scheme, value)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
119 )
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
120 WITHOUT OIDS;
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
121
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
122 -- classification of PRs according to the hierarchical schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
123 CREATE TABLE hierclass_data (
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
124 pr bigint not null references PRs (id),
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
125 scheme text not null references hierclass_names (name),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
126 value text ,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
127 primary key (pr, scheme),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
128 --
29
David A. Holland
parents: 23
diff changeset
129 -- Ok, the intended semantics here are:
David A. Holland
parents: 23
diff changeset
130 -- * For PRs that the classification doesn't apply to, there
David A. Holland
parents: 23
diff changeset
131 -- should be no row at all in the *class_data table.
David A. Holland
parents: 23
diff changeset
132 -- * For PRs where the classification is undetermined or
David A. Holland
parents: 23
diff changeset
133 -- unassigned, the value column should be null, and if
David A. Holland
parents: 23
diff changeset
134 -- that's allowed there should be a null entry in
David A. Holland
parents: 23
diff changeset
135 -- the *class_values table.
David A. Holland
parents: 23
diff changeset
136 -- I believe "MATCH SIMPLE" to be capable of enforcing this,
David A. Holland
parents: 23
diff changeset
137 -- but that's from reading postgres docs and not from actually
David A. Holland
parents: 23
diff changeset
138 -- checking it. From the description, "MATCH FULL" will do the
David A. Holland
parents: 23
diff changeset
139 -- wrong thing, and "MATCH PARTIAL" isn't supported.
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
140 --
29
David A. Holland
parents: 23
diff changeset
141 foreign key (scheme, value) references hierclass_values (scheme, value)
David A. Holland
parents: 23
diff changeset
142 MATCH FULL
David A. Holland
parents: 23
diff changeset
143 ON DELETE RESTRICT
David A. Holland
parents: 23
diff changeset
144 ON UPDATE RESTRICT
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
145 )
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
146 WITHOUT OIDS;
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
147
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
148 ------------------------------------------------------------
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
149 -- Enumerated flat schemes.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
150
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
151 -- names and properties of the flat schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
152 CREATE TABLE flatclass_names (
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
153 name text primary key,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
154 ordering int not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
155 total boolean not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
156 description text not null
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
157 )
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
158 WITHOUT OIDS;
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
159
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
160 -- allowed values of the flat schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
161 CREATE TABLE flatclass_values (
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
162 scheme text not null references flatclass_names (name),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
163 value text not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
164 ordering int not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
165 obsolete boolean not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
166 description text not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
167 primary key (scheme, value)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
168 )
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
169 WITHOUT OIDS;
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
170
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
171 -- classification of PRs according to the flat schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
172 CREATE TABLE flatclass_data (
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
173 pr bigint not null references PRs (id),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
174 scheme text not null references flatclass_names (name),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
175 value text ,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
176 primary key (pr, scheme),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
177 -- as above
29
David A. Holland
parents: 23
diff changeset
178 foreign key (scheme, value) references flatclass_values (scheme, value)
David A. Holland
parents: 23
diff changeset
179 MATCH FULL
David A. Holland
parents: 23
diff changeset
180 ON DELETE RESTRICT
David A. Holland
parents: 23
diff changeset
181 ON UPDATE RESTRICT
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
182 )
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
183 WITHOUT OIDS;
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
184
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
185 ------------------------------------------------------------
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
186 -- Text schemes.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
187
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
188 -- names and properties of the text schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
189 CREATE TABLE textclass_names (
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
190 name text primary key,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
191 ordering int not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
192 total boolean not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
193 description text not null
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
194 )
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
195 WITHOUT OIDS;
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
196
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
197 -- classification of PRs according to the text schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
198 CREATE TABLE textclass_data (
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
199 pr bigint not null references PRs (id),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
200 scheme text not null references textclass_names (name),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
201 value text ,
29
David A. Holland
parents: 23
diff changeset
202 primary key (pr, scheme)
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
203 )
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
204 WITHOUT OIDS;
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
205
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
206 ------------------------------------------------------------
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
207 -- Tag schemes.
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
208
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
209 -- names and properties of the tag schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
210 -- (total does not make sense here)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
211 CREATE TABLE tagclass_names (
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
212 name text primary key,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
213 ordering int not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
214 description text not null
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
215 )
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
216 WITHOUT OIDS;
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
217
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
218 -- allowed values of the tag schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
219 -- (each PR can reference zero or more of these)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
220 CREATE TABLE tagclass_values (
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
221 scheme text not null references tagclass_names (name),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
222 value text not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
223 ordering int not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
224 obsolete boolean not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
225 description text not null,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
226 primary key (scheme, value)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
227 )
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
228 WITHOUT OIDS;
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
229
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
230 -- classification of PRs according to the tag schemes
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
231 -- (each PR/scheme pair is listed once for each tag attached to it)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
232 CREATE TABLE tagclass_data (
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
233 pr bigint not null references PRs (id),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
234 scheme text not null references tagclass_names (name),
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
235 value text ,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
236 -- as above
29
David A. Holland
parents: 23
diff changeset
237 foreign key (scheme, value) references tagclass_values (scheme, value)
David A. Holland
parents: 23
diff changeset
238 MATCH FULL
David A. Holland
parents: 23
diff changeset
239 ON DELETE RESTRICT
David A. Holland
parents: 23
diff changeset
240 ON UPDATE RESTRICT
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
241 )
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
242 WITHOUT OIDS;
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
243
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
244 -- view where tags are collected into a string
29
David A. Holland
parents: 23
diff changeset
245 -- string_agg() concatenates the value strings
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
246 CREATE VIEW tagclass_stringdata AS
29
David A. Holland
parents: 23
diff changeset
247 SELECT pr,
David A. Holland
parents: 23
diff changeset
248 tagclass_data.scheme as scheme,
David A. Holland
parents: 23
diff changeset
249 string_agg(tagclass_data.value, ' '
David A. Holland
parents: 23
diff changeset
250 ORDER BY tagclass_values.ordering) as value
David A. Holland
parents: 23
diff changeset
251 FROM tagclass_data, tagclass_values
David A. Holland
parents: 23
diff changeset
252 WHERE
David A. Holland
parents: 23
diff changeset
253 tagclass_data.scheme = tagclass_values.scheme
David A. Holland
parents: 23
diff changeset
254 AND tagclass_data.value = tagclass_values.value
David A. Holland
parents: 23
diff changeset
255 GROUP BY pr, tagclass_data.scheme
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
256 ;
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
257
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
258 ------------------------------------------------------------
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
259 -- some views
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
260
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
261 -- views that pull in the ordering fields.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
262 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
263 -- (If you use only one of the ordering fields, as is likely to be
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
264 -- the case in practice, I think we can rely on the query optimizer
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
265 -- to drop the join that collects in the other ordering field. If
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
266 -- not, maybe this should be restructured.)
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
267 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
268 -- XXX what do these do when _data.value is null?
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
269
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
270 CREATE VIEW hierclass_data_ordered AS
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
271 SELECT hierclass_data.pr as pr,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
272 hierclass_data.scheme as scheme,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
273 hierclass_names.ordering as schemeordering,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
274 hierclass_data.value as value,
29
David A. Holland
parents: 23
diff changeset
275 hierclass_values.ordering as valueordering
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
276 FROM hierclass_data, hierclass_names, hierclass_values
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
277 WHERE
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
278 hierclass_data.scheme = hierclass_names.name
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
279 AND hierclass_data.scheme = hierclass_values.scheme
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
280 AND hierclass_data.value = hierclass_values.value
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
281 ;
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
282
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
283 CREATE VIEW flatclass_data_ordered AS
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
284 SELECT flatclass_data.pr as pr,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
285 flatclass_data.scheme as scheme,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
286 flatclass_names.ordering as schemeordering,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
287 flatclass_data.value as value,
29
David A. Holland
parents: 23
diff changeset
288 flatclass_values.ordering as valueordering
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
289 FROM flatclass_data, flatclass_names, flatclass_values
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
290 WHERE
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
291 flatclass_data.scheme = flatclass_names.name
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
292 AND flatclass_data.scheme = flatclass_values.scheme
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
293 AND flatclass_data.value = flatclass_values.value
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
294 ;
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
295
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
296 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
297 -- XXX what I'd like to do here is produce textclass_data.value as
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
298 -- valueordering; then sorting by valueordering would produce the
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
299 -- desired results (the entries sorted by text order of the values).
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
300 -- That produces a type conflict though if we combine this view
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
301 -- with the other ordered views where the ordering is a number.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
302 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
303 -- Next best would be to order by textclass_data.value in this view
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
304 -- and produce the row number of the result (or some other fresh
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
305 -- sequence) as valueordering. However, I don't think that's possible.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
306 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
307 -- What's here (using a fixed value of 1) will run but it's not
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
308 -- particularly desirable.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
309 --
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
310 CREATE VIEW textclass_data_ordered AS
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
311 SELECT textclass_data.pr as pr,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
312 textclass_data.scheme as scheme,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
313 textclass_names.ordering as schemeordering,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
314 textclass_data.value as value,
29
David A. Holland
parents: 23
diff changeset
315 1 as valueordering
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
316 FROM textclass_data, textclass_names
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
317 WHERE
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
318 textclass_data.scheme = textclass_names.name
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
319 ;
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
320
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
321 CREATE VIEW tagclass_data_ordered AS
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
322 SELECT tagclass_data.pr as pr,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
323 tagclass_data.scheme as scheme,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
324 tagclass_names.ordering as schemeordering,
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
325 tagclass_data.value as value,
29
David A. Holland
parents: 23
diff changeset
326 tagclass_values.ordering as valueordering
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
327 FROM tagclass_data, tagclass_names, tagclass_values
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
328 WHERE
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
329 tagclass_data.scheme = tagclass_names.name
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
330 AND tagclass_data.scheme = tagclass_values.scheme
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
331 AND tagclass_data.value = tagclass_values.value
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
332 ;
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
333
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
334 -- ordered version of tagclass_stringdata
29
David A. Holland
parents: 23
diff changeset
335 --
David A. Holland
parents: 23
diff changeset
336 -- Note that schemeordering is uniquely defined by the group-by
David A. Holland
parents: 23
diff changeset
337 -- and the min() on it is there to satisfy the cookiemonster.
David A. Holland
parents: 23
diff changeset
338 --
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
339 CREATE VIEW tagclass_stringdata_ordered AS
29
David A. Holland
parents: 23
diff changeset
340 SELECT pr, scheme, min(schemeordering),
David A. Holland
parents: 23
diff changeset
341 string_agg(value, ' ' ORDER BY valueordering) as value,
David A. Holland
parents: 23
diff changeset
342 min(valueordering) as valueordering
David A. Holland
parents: 23
diff changeset
343 FROM tagclass_data_ordered
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
344 GROUP BY pr, scheme
8
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
345 ;
68cc276ac118 SQL material from old tree, split up for accessibility.
David A. Holland
parents:
diff changeset
346
11
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
347
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
348 -- a view that combines all the classification data.
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
349
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
350 CREATE VIEW classifications AS
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
351 SELECT * FROM hierclass_data_ordered
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
352 UNION SELECT * FROM flatclass_data_ordered
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
353 UNION SELECT * FROM textclass_data_ordered
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
354 UNION SELECT * FROM tagclass_stringdata_ordered
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
355 ORDER BY schemeordering
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
356 ;
d42c0db81e28 Update the classification stuff.
David A. Holland
parents: 8
diff changeset
357