 CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE
 	ON items FOR EACH ROW EXECUTE PROCEDURE
 	tsvector_update_trigger(tsv, 'pg_catalog.english', item_name, keywords);
-CREATE TABLE item_procs(item_id integer REFERENCES items(item_id), proc_name text,
-proc_type varchar(25), proc_desc varchar(25), proc_trig varchar(25), proc_effect varchar(25),
-PRIMARY KEY (item_id, proc_name));
-CREATE TABLE item_slots(item_id integer REFERENCES items(item_id), slot_abbr varchar(10)
-REFERENCES slots(slot_abbr), PRIMARY KEY (item_id, slot_abbr));
-CREATE TABLE item_flags(item_id integer REFERENCES items(item_id), flag_abbr varchar(10)
-REFERENCES flags(flag_abbr), PRIMARY KEY (item_id, flag_abbr));
-CREATE TABLE item_restricts(item_id integer REFERENCES items(item_id), restrict_abbr varchar(10)
-REFERENCES restricts(restrict_abbr), PRIMARY KEY (item_id, restrict_abbr));
-CREATE TABLE item_resists(item_id integer REFERENCES items(item_id), resist_abbr varchar(10)
-REFERENCES resists(resist_abbr), resist_value integer, PRIMARY KEY (item_id, resist_abbr));
-CREATE TABLE item_effects(item_id integer REFERENCES items(item_id), effect_abbr varchar(10)
-REFERENCES effects(effect_abbr), PRIMARY KEY (item_id, effect_abbr));
-CREATE TABLE item_specials(item_id integer REFERENCES items(item_id), item_type varchar(10),
-spec_abbr varchar(10), spec_value varchar(30),
-FOREIGN KEY (item_type, spec_abbr) REFERENCES specials (item_type, spec_abbr),
-PRIMARY KEY (item_id, item_type, spec_abbr));
-CREATE TABLE item_enchants(item_id integer REFERENCES items(item_id), ench_name varchar(25)
-REFERENCES enchants(ench_name), dam_pct integer, freq_pct integer,
-sv_mod integer, duration integer, PRIMARY KEY (item_id, ench_name));
+CREATE TABLE item_procs(
+	item_id integer REFERENCES items(item_id)
+	,proc_name text
+	,proc_type varchar(25)
+	,proc_desc varchar(25)
+	,proc_trig varchar(25)
+	,proc_effect varchar(25)
+	,PRIMARY KEY (item_id, proc_name)
+);
+CREATE TABLE item_slots(
+	item_id integer REFERENCES items(item_id)
+	,slot_abbr varchar(10) REFERENCES slots(slot_abbr)
+	,PRIMARY KEY (item_id, slot_abbr)
+);
+CREATE TABLE item_flags(
+	item_id integer REFERENCES items(item_id)
+	,flag_abbr varchar(10) REFERENCES flags(flag_abbr)
+	,PRIMARY KEY (item_id, flag_abbr)
+);
+CREATE TABLE item_restricts(
+	item_id integer REFERENCES items(item_id)
+	,restrict_abbr varchar(10) REFERENCES restricts(restrict_abbr)
+	,PRIMARY KEY (item_id, restrict_abbr)
+);
+CREATE TABLE item_resists(
+	item_id integer REFERENCES items(item_id)
+	,resist_abbr varchar(10) REFERENCES resists(resist_abbr)
+	,resist_value integer
+	,PRIMARY KEY (item_id, resist_abbr)
+);
+CREATE TABLE item_effects(
+	item_id integer REFERENCES items(item_id)
+	,effect_abbr varchar(10) REFERENCES effects(effect_abbr)
+	,PRIMARY KEY (item_id, effect_abbr)
+);
+CREATE TABLE item_specials(
+	item_id integer REFERENCES items(item_id)
+	,item_type varchar(10)
+	,spec_abbr varchar(10)
+	,spec_value varchar(30)
+	,FOREIGN KEY (item_type, spec_abbr) REFERENCES specials (item_type, spec_abbr)
+	,PRIMARY KEY (item_id, item_type, spec_abbr)
+);
+CREATE TABLE item_enchants(
+	item_id integer REFERENCES items(item_id)
+	,ench_name varchar(25) REFERENCES enchants(ench_name)
+	,dam_pct integer
+	,freq_pct integer
+	,sv_mod integer
+	,duration integer
+	,PRIMARY KEY (item_id, ench_name)
+);
+CREATE TABLE item_attribs(
+	item_id integer REFERENCES items(item_id)
+	,attrib_abbr varchar(25) REFERENCES attribs(attrib_abbr)
+	,attrib_value integer
+	,PRIMARY KEY (item_id, attrib_abbr)
+);

INSERT INTO effects VALUES('blind', 'BLINDNESS', 'Blindness');
INSERT INTO effects VALUES('slow', 'SLOW', 'Slowness');
INSERT INTO effects VALUES('ultra', 'ULTRA', 'Ultravision');
CREATE TABLE resists(resist_abbr varchar(10) PRIMARY KEY, resist_name varchar(25),
resist_display varchar(25));
INSERT INTO resists VALUES('fire', 'Fire', 'Fire');
INSERT INTO resists VALUES('cold', 'Cold', 'Cold');
INSERT INTO resists VALUES('acid', 'Acid', 'Acid');

INSERT INTO zones VALUES('Graydawn', 'Valley of Graydawn');
INSERT INTO zones VALUES('Crushk', 'Valley of Crushk');
INSERT INTO zones VALUES('Unknown', 'Unknown');
CREATE TABLE mobs(
	mob_name varchar(150) PRIMARY KEY
	,mob_abbr varchar(25)
	,from_zone varchar(10) REFERENCES zones(zone_abbr)
	,from_quest boolean
	,has_quest boolean
	,is_rare boolean
	,from_invasion boolean
);
CREATE TABLE specials(
	item_type varchar(10) REFERENCES item_types(type_abbr)
	,spec_abbr varchar(10)
	,spec_display varchar(25)
	,PRIMARY KEY (item_type, spec_abbr)
);
INSERT INTO specials VALUES('armor', 'AC', 'Armor Class'); -- intac
INSERT INTO specials VALUES('crystal', 'psp', 'Crystal PSP'); -- varpsp
INSERT INTO specials VALUES('spellbook', 'pages', 'Pages'); -- varpages
INSERT INTO specials VALUES('container', 'holds', 'Capacity'); -- varholds
