]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/metadata/sql/fill_all_derived.sql
added the count table
[helm.git] / helm / metadata / sql / fill_all_derived.sql
diff --git a/helm/metadata/sql/fill_all_derived.sql b/helm/metadata/sql/fill_all_derived.sql
new file mode 100644 (file)
index 0000000..708015b
--- /dev/null
@@ -0,0 +1,64 @@
+CREATE TABLE no_inconcl_aux_tmp (
+    source varchar(255) binary unique not null,
+    no smallint(6) not null
+);
+CREATE TABLE no_concl_hyp_tmp (
+    source varchar(255) binary unique not null,
+    no smallint(6) not null
+);
+CREATE TABLE no_hyp_tmp (
+    source varchar(255) binary unique not null,
+    no smallint(6) not null
+);
+
+INSERT INTO no_inconcl_aux_tmp
+SELECT source, COUNT(h_occurrence)
+FROM refObj
+WHERE
+  h_position='http://www.cs.unibo.it/helm/schemas/schema-helm#InConclusion'
+  OR h_position='http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion'
+GROUP BY source;
+
+INSERT IGNORE INTO no_inconcl_aux_tmp
+SELECT source, 0
+FROM refObj
+GROUP BY source;
+
+INSERT INTO no_concl_hyp_tmp
+SELECT source, COUNT(DISTINCT h_occurrence)
+FROM refObj
+WHERE NOT (h_position="http://www.cs.unibo.it/helm/schemas/schema-helm#InBody")
+GROUP BY source;
+
+INSERT IGNORE INTO no_concl_hyp_tmp
+SELECT source, 0
+FROM refObj
+GROUP BY source;
+
+INSERT INTO no_hyp_tmp
+SELECT source, COUNT(DISTINCT h_occurrence)
+FROM refObj
+WHERE (h_position="http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis"
+    OR h_position="http://www.cs.unibo.it/helm/schemas/schema-helm#InHypothesis")
+GROUP BY source;
+
+INSERT IGNORE INTO no_hyp_tmp
+SELECT source, 0
+FROM refObj
+GROUP BY source;
+
+INSERT INTO count
+SELECT no_hyp_tmp.source, 
+       no_inconcl_aux_tmp.no, 
+       no_hyp_tmp.no, 
+       no_concl_hyp_tmp.no
+FROM no_hyp_tmp, no_concl_hyp_tmp, no_inconcl_aux_tmp
+WHERE no_hyp_tmp.source = no_concl_hyp_tmp.source AND
+      no_hyp_tmp.source = no_inconcl_aux_tmp.source;
+
+DROP TABLE no_hyp_tmp;
+DROP TABLE no_inconcl_aux_tmp;
+DROP TABLE no_concl_hyp_tmp;
+
+
+