 -- Entry Relations
 
 CREATE TABLE creature_creature_relation_types (
-	id int(11) auto_increment,
-	`a_to_b_type` varchar(32),
-	`b_to_a_type` varchar(32),
-    unique key (`a_to_b_type`),
-    unique key (`b_to_a_type`),
+    id INT(11) AUTO_INCREMENT,
+    `a_to_b_type` VARCHAR(32),
+    `b_to_a_type` VARCHAR(32),
+    UNIQUE KEY (`a_to_b_type`),
+    UNIQUE KEY (`b_to_a_type`),
     PRIMARY KEY (id)
 );
 
 CREATE TABLE creature_creature_relations (
-	creature_a int(11),
-    creature_b int(11),
-    relation_type_id int(11),
+    creature_a INT(11),
+    creature_b INT(11),
+    relation_type_id INT(11),
     FOREIGN KEY (creature_a)
         REFERENCES creatures (entry_id)
         ON UPDATE CASCADE ON DELETE CASCADE,

);
    
CREATE TABLE damage_types (
	damage_type varchar(32),
    primary key (damage_type)
);

CREATE TABLE conditions (
	`condition` varchar(32),
    primary key (`condition`)
);

CREATE TABLE creature_damage_type_modifiers (
	creature_entry_id int(11),
    damage_type varchar(32),
    modifier double DEFAULT 1,
    FOREIGN KEY (creature_entry_id)
        REFERENCES creatures (entry_id)
        ON UPDATE CASCADE ON DELETE CASCADE,
    FOREIGN KEY (damage_type)
        REFERENCES damage_types (damage_type)
        ON UPDATE CASCADE ON DELETE CASCADE,
    primary key (creature_entry_id, damage_type)
);

CREATE TABLE creature_condition_immunities (
	creature_entry_id int(11),
    `condition` varchar(32),
    FOREIGN KEY (creature_entry_id)
        REFERENCES creatures (entry_id)
        ON UPDATE CASCADE ON DELETE CASCADE,
    FOREIGN KEY (`condition`)
        REFERENCES creature_damage_type_modifiers (`condition`)
        ON UPDATE CASCADE ON DELETE CASCADE,
    primary key (creature_entry_id, `condition`)
);



    FOREIGN KEY (relation_type_id)
        REFERENCES creature_creature_relation_types (id)
        ON UPDATE CASCADE ON DELETE CASCADE,
    PRIMARY KEY (creature_a , creature_b , relation_type_id)
)
