CREATE TABLE dict (
       word                 VARCHAR2(32) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;

CREATE INDEX dict_word   ON dict (word);
CREATE INDEX dict_url_id ON dict (url_id);


CREATE TABLE url (
       rec_id               NUMBER(12) NOT NULL,
       status               NUMBER(6) DEFAULT 0 NOT NULL,
       docsize              NUMBER(12) DEFAULT 0 NOT NULL,
       next_index_time      NUMBER(12) NULL,
       last_mod_time        NUMBER(12) DEFAULT 0 NOT NULL,
       since                NUMBER(12) DEFAULT 0 NOT NULL,
       referrer             NUMBER(12) DEFAULT 0 NOT NULL,
       hops                 NUMBER(6) DEFAULT 0 NOT NULL,
       crc32                NUMBER(12) DEFAULT -1 NOT NULL,
       seed                 NUMBER(6) DEFAULT 0 NOT NULL,
       bad_since_time       NUMBER(12) NULL,
       site_id		    NUMBER(12),
       server_id	    NUMBER(12),
       charset_id           NUMBER(6),
       pop_rank	  	    FLOAT DEFAULT 0.0 NOT NULL,
       url                  VARCHAR2(128) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;

CREATE UNIQUE INDEX url_url ON url (url ASC);
CREATE INDEX url_rec_id ON url (rec_id);
CREATE INDEX url_crc32 ON url (crc32 ASC);
CREATE INDEX url_next_index_time_ind ON url (next_index_time);

CREATE SEQUENCE next_url_id INCREMENT BY 1 START WITH 1;


CREATE TABLE urlinfo (
       url_id NUMBER(38) NOT NULL,
       sname  VARCHAR2(64) NOT NULL,
       sval   VARCHAR2(1024)
);

CREATE INDEX urlinfo_id_ind ON urlinfo (url_id);


CREATE TABLE server (
	rec_id          NUMBER          DEFAULT 0   NOT NULL, 
	enabled		NUMBER		DEFAULT 0   NOT NULL,
	url		VARCHAR2(128)	DEFAULT ''  NOT NULL,
	period		NUMBER		DEFAULT 604800 NOT NULL,
	tag		VARCHAR2(16)	DEFAULT '',
	category	VARCHAR2(16)	DEFAULT ''  NOT NULL,
	command		CHAR(1)		DEFAULT 'S' NOT NULL,
	ordre		NUMBER		DEFAULT 0   NOT NULL,
	parent		NUMBER		DEFAULT 0   not null,
	weight		float		DEFAULT 1   not null,
	pop_weight	float		DEFAULT 0   not null
);

CREATE SEQUENCE server_rec_id_seq INCREMENT BY 1 START WITH 1;

ALTER TABLE server ADD CONSTRAINT server_pk PRIMARY KEY (rec_id);
CREATE UNIQUE INDEX srv_url ON server (url); 
CREATE INDEX srv_ordre ON server (ordre);
CREATE INDEX srv_parent ON server (parent);
CREATE INDEX srv_command ON server (command);


CREATE TABLE srvinfo (
     srv_id int           NOT NULL,
     sname  varchar(96)   NOT NULL,
     sval   varchar(1024) NOT NULL
);
CREATE INDEX srvinfo_id ON srvinfo (srv_id);


	     
CREATE TABLE links (
	ot	 NUMBER not null,
	k	 NUMBER not null,
	weight   FLOAT DEFAULT 0.0 not null,
	valid    CHAR(1) DEFAULT 't' not null
);

CREATE UNIQUE INDEX links_links ON links (ot, k);
CREATE INDEX links_ot ON links (ot);
CREATE INDEX links_k ON links (k);

CREATE TABLE categories (
  rec_id int    NOT NULL PRIMARY KEY,
  path char(10) DEFAULT '' NOT NULL,
  link char(10) DEFAULT '' NOT NULL,
  name char(64) DEFAULT '' NOT NULL
);

CREATE INDEX cat_path ON categories (path);
CREATE INDEX cat_link ON categories (link);

CREATE TABLE dict10 (
       word                 VARCHAR2(10) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;

CREATE INDEX dict10_url_ind ON dict10
(
       url_id
);

CREATE INDEX dict10_word_ind ON dict10
(
    word
);


CREATE TABLE dict11 (
       word                 VARCHAR2(11) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict11_url_ind ON dict11
(
       url_id
);

CREATE INDEX dict11_word_ind ON dict11
(
       word
);


CREATE TABLE dict12 (
       word                 VARCHAR2(12) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict12_url_ind ON dict12
(
       url_id
);

CREATE INDEX dict12_word_ind ON dict12
(
       word
);


CREATE TABLE dict16 (
       word                 VARCHAR2(16) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict16_url_ind ON dict16
(
       url_id
);

CREATE INDEX dict16_word_ind ON dict16
(
       word
);


CREATE TABLE dict2 (
       word                 VARCHAR2(2) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict2_url_ind ON dict2
(
       url_id
);

CREATE INDEX dict2_word_ind ON dict2
(
       word
);


CREATE TABLE dict3 (
       word                 VARCHAR2(3) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict3_url_ind ON dict3
(
       url_id
);

CREATE INDEX dict3_word_ind ON dict3
(
       word
);


CREATE TABLE dict32 (
       word                 VARCHAR2(32) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict32_url_ind ON dict32
(
       url_id
);

CREATE INDEX dict32_word_ind ON dict32
(
       word
);


CREATE TABLE dict4 (
       word                 VARCHAR2(4) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict4_url_ind ON dict4
(
       url_id
);

CREATE INDEX dict4_word_ind ON dict4
(
       word
);

CREATE TABLE dict5 (
       word                 VARCHAR2(5) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict5_url_ind ON dict5
(
       url_id
);

CREATE INDEX dict5_word_ind ON dict5
(
       word
);


CREATE TABLE dict6 (
       word                 VARCHAR2(6) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict6_url_ind ON dict6
(
       url_id
);

CREATE INDEX dict6_word_ind ON dict6
(
       word
);


CREATE TABLE dict7 (
       word                 VARCHAR2(7) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict7_url_ind ON dict7
(
       url_id
);

CREATE INDEX dict7_word_ind ON dict7
(
       word
);


CREATE TABLE dict8 (
       word                 VARCHAR2(8) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict8_url_ind ON dict8
(
       url_id
);

CREATE INDEX dict8_word_ind ON dict8
(
       word
);


CREATE TABLE dict9 (
       word                 VARCHAR2(9) NOT NULL,
       url_id               NUMBER(12) NOT NULL,
       intag                NUMBER(12) NOT NULL
)
       PCTFREE 5
       PCTUSED 95
;


CREATE INDEX dict9_url_ind ON dict9
(
       url_id
);

CREATE INDEX dict9_word_ind ON dict9
(
       word
);

