drop table link;
drop table url;
drop table word;
drop table word_to_link;
drop table word_to_url;
drop table url_to_text;

CREATE TABLE link (
	lid		INTEGER NOT NULL AUTO_INCREMENT,
	lurl	INTEGER,
	pos		INTEGER,
	urlid	INTEGER,
	PRIMARY KEY(lid)
);

CREATE TABLE url (
	urlid	INTEGER NOT NULL,
	url		VARCHAR(255),
	rank	FLOAT  DEFAULT 1.0,
	PRIMARY KEY(urlid)
);

CREATE TABLE word (
	wid		INTEGER NOT NULL,
	word	VARCHAR(255),
	INDEX wordIndex(word(10)),
	PRIMARY KEY(wid)
);

CREATE TABLE word_to_link (
	lid		INTEGER,
	pos		INTEGER,
	urlid	INTEGER,
	wid		INTEGER
);

CREATE TABLE word_to_url (
	wid		INTEGER,
	pos		INTEGER,
	tag		SET('h1','h2','h3','h4','h5','h6','b','i','u','img','title','meta'),
	urlid	INTEGER
);

CREATE TABLE url_to_text (
	urlid		INTEGER NOT NULL,
	header		VARCHAR(255),
	text		LONGTEXT,
	PRIMARY KEY(urlid)
);		
