]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/metadata/sqlStatements.ml
- renamed ocaml/ to components/
[helm.git] / helm / ocaml / metadata / sqlStatements.ml
diff --git a/helm/ocaml/metadata/sqlStatements.ml b/helm/ocaml/metadata/sqlStatements.ml
deleted file mode 100644 (file)
index a080739..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-(* Copyright (C) 2004-2005, HELM Team.
- * 
- * This file is part of HELM, an Hypertextual, Electronic
- * Library of Mathematics, developed at the Computer Science
- * Department, University of Bologna, Italy.
- * 
- * HELM is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * 
- * HELM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HELM; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA  02111-1307, USA.
- * 
- * For details, see the HELM World-Wide-Web page,
- * http://helm.cs.unibo.it/
- *)
-
-(* $Id$ *)
-
-open Printf;;
-type tbl = [ `RefObj| `RefSort| `RefRel| `ObjectName| `Hits| `Count]
-
-(* TABLES *)
-
-let sprintf_refObj_format name = [
-sprintf "CREATE TABLE %s (
-    source varchar(255) binary not null,
-    h_occurrence varchar(255) binary not null,
-    h_position varchar(62) binary not null,
-    h_depth integer
-);" name]
-
-let sprintf_refSort_format name = [
-sprintf "CREATE TABLE %s (
-    source varchar(255) binary not null,
-    h_position varchar(62) binary not null,
-    h_depth integer not null,
-    h_sort varchar(5) binary not null
-);" name]
-
-let sprintf_refRel_format name = [
-sprintf "CREATE TABLE %s (
-    source varchar(255) binary not null,
-    h_position varchar(62) binary not null,
-    h_depth integer not null
-);" name]
-
-let sprintf_objectName_format name = [
-sprintf "CREATE TABLE %s (
-    source varchar(255) binary not null,
-    value varchar(255) binary not null
-);" name]
-
-let sprintf_hits_format name = [
-sprintf "CREATE TABLE %s (
-    source varchar(255) binary not null,
-    no integer not null
-);" name]
-
-let sprintf_count_format name = [
-sprintf "CREATE TABLE %s (
-    source varchar(255) binary unique not null,
-    conclusion smallint(6) not null,
-    hypothesis smallint(6) not null,
-    statement smallint(6) not null
-);" name]
-
-let sprintf_refObj_drop name = [sprintf "DROP TABLE %s;" name]
-
-let sprintf_refSort_drop name = [sprintf "DROP TABLE %s;" name]
-
-let sprintf_refRel_drop name = [sprintf "DROP TABLE %s;" name]
-
-let sprintf_objectName_drop name = [sprintf "DROP TABLE %s;" name]
-
-let sprintf_hits_drop name = [sprintf "DROP TABLE %s;" name]
-
-let sprintf_count_drop name = [sprintf "DROP TABLE %s;" name]
-
-(* INDEXES *)
-
-let sprintf_refObj_index name = [
-sprintf "CREATE INDEX %s_index ON %s (source(219),h_occurrence(219),h_position);" name name;
-sprintf "CREATE INDEX %s_occurrence ON %s (h_occurrence);" name name ]
-
-let sprintf_refSort_index name = [
-sprintf "CREATE INDEX %s_index ON %s (source,h_sort,h_position,h_depth);" name name]
-
-let sprintf_objectName_index name = [
-sprintf "CREATE INDEX %s_value ON %s (value);" name name]
-
-let sprintf_hits_index name = [
-sprintf "CREATE INDEX %s_source ON %s (source);" name name ;
-sprintf "CREATE INDEX %s_no ON %s (no);" name name] 
-
-let sprintf_count_index name = [
-sprintf "CREATE INDEX %s_conclusion ON %s (conclusion);" name name;
-sprintf "CREATE INDEX %s_hypothesis ON %s (hypothesis);" name name;
-sprintf "CREATE INDEX %s_statement ON %s (statement);" name name]
-let sprintf_refRel_index name = [
-sprintf "CREATE INDEX %s_index ON %s (source,h_position,h_depth);" name name]
-
-let sprintf_refObj_index_drop name = [
-sprintf "DROP INDEX %s_index ON %s;" name name ]
-
-let sprintf_refSort_index_drop name = [
-sprintf "DROP INDEX %s_index ON %s;" name name ]
-
-let sprintf_objectName_index_drop name = [
-sprintf "DROP INDEX %s_value ON %s;" name name]
-
-let sprintf_hits_index_drop name = [
-sprintf "DROP INDEX %s_source ON %s;" name name ;
-sprintf "DROP INDEX %s_no ON %s;" name name] 
-
-let sprintf_count_index_drop name = [
-sprintf "DROP INDEX %s_source ON %s;" name name;
-sprintf "DROP INDEX %s_conclusion ON %s;" name name;
-sprintf "DROP INDEX %s_hypothesis ON %s;" name name;
-sprintf "DROP INDEX %s_statement ON %s;" name name]
-let sprintf_refRel_index_drop name = [
-sprintf "DROP INDEX %s_index ON %s;" name name]
-
-let sprintf_rename_table oldname newname = [
-sprintf "RENAME TABLE %s TO %s;" oldname newname 
-]
-          
-
-(* FUNCTIONS *)
-
-let get_table_format t named =
-  match t with
-  | `RefObj -> sprintf_refObj_format named
-  | `RefSort -> sprintf_refSort_format named
-  | `RefRel -> sprintf_refRel_format named
-  | `ObjectName -> sprintf_objectName_format named
-  | `Hits -> sprintf_hits_format named
-  | `Count -> sprintf_count_format named
-
-let get_index_format t named =
-  match t with
-  | `RefObj -> sprintf_refObj_index named
-  | `RefSort -> sprintf_refSort_index named
-  | `RefRel -> sprintf_refRel_index named
-  | `ObjectName -> sprintf_objectName_index named
-  | `Hits -> sprintf_hits_index named
-  | `Count -> sprintf_count_index named
-
-let get_table_drop t named =
-  match t with
-  | `RefObj -> sprintf_refObj_drop named
-  | `RefSort -> sprintf_refSort_drop named
-  | `RefRel -> sprintf_refRel_drop named
-  | `ObjectName -> sprintf_objectName_drop named
-  | `Hits -> sprintf_hits_drop named
-  | `Count -> sprintf_count_drop named
-
-let get_index_drop t named =
-  match t with
-  | `RefObj -> sprintf_refObj_index_drop named
-  | `RefSort -> sprintf_refSort_index_drop named
-  | `RefRel -> sprintf_refRel_index_drop named
-  | `ObjectName -> sprintf_objectName_index_drop named
-  | `Hits -> sprintf_hits_index_drop named
-  | `Count -> sprintf_count_index_drop named
-
-let create_tables l =
-  List.fold_left (fun s (name,table) ->  s @ get_table_format table name) [] l
-
-let create_indexes l =
-  List.fold_left (fun s (name,table) ->  s @ get_index_format table name) [] l
-let drop_tables l =
-  List.fold_left (fun s (name,table) ->  s @ get_table_drop table name) [] l
-  
-let drop_indexes l =
-  List.fold_left (fun s (name,table) ->  s @ get_index_drop table name) [] l
-
-let rename_tables l = 
-  List.fold_left (fun s (o,n) ->  s @ sprintf_rename_table o n) [] l
-
-let fill_hits refObj hits =
-  [ sprintf
-        "INSERT INTO %s
-        SELECT h_occurrence, COUNT(source)
-        FROM %s
-        GROUP BY h_occurrence;"
-      hits refObj ]
-
-