CREATE TABLE "openfields" ("sheet_id" "int4", "code" "int2", "value" "int4"); CREATE TABLE "codes" ("code_id" "int4", "name" "text"); CREATE TABLE "cat" ("cat_id" "int4", "call" "text", "main_entry" "text", "series" "text"); CREATE TABLE "sheet" ("fil_no" "int4", "sheet_id" "int4", "name" "text", "number" "text", "note" "text", "holdings" "int2", "cat_id" "int4", "mtype" "int2", "prod" "int2", "proj" "int2", "pm" "int2", "format" "int2", "scale" "int4", "coords" "box"); CREATE TABLE "gnis_state" ("id" "int4", "abbrev" varchar(4), "name" "text"); CREATE TABLE "gnis_ftype" ("id" "int4", "abbrev" char(8), "name" "text"); CREATE TABLE "gnis_county" ("id" "int4", "state" "int4", "name" "text"); CREATE TABLE "gnis" ("fname" "text", "fname_lc" "text", "ftype" "int4", "state" "int4", "county" "int4", "elevation" "int4", "population" "int4", "location" "point"); CREATE FUNCTION "codetext" ("int2" ) RETURNS "text" AS 'SELECT codes.name where codes.code_id = $1;' LANGUAGE 'SQL'; CREATE INDEX "i_openfields" on "openfields" using btree ( "sheet_id" "int4_ops" ); CREATE INDEX "i_codes" on "codes" using btree ( "code_id" "int4_ops" ); CREATE INDEX "i_cat" on "cat" using hash ( "cat_id" "int4_ops" ); CREATE INDEX "i_sheet" on "sheet" using btree ( "sheet_id" "int4_ops" ); CREATE INDEX "i_sheetname" on "sheet" using btree ( "name" "text_ops" ); CREATE INDEX "i_sheetcoords" on "sheet" using rtree ( "coords" "box_ops" ); CREATE INDEX "gnis_state_i" on "gnis_state" using btree ( "id" "int4_ops" ); CREATE INDEX "gnis_county_i" on "gnis_county" using btree ( "id" "int4_ops" ); CREATE INDEX "gnis_i" on "gnis" using btree ( "fname_lc" "text_ops" );