 -- 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,

insert into alignments (alignment) values ('lawful-good'), ('lawful-neutral'), ('lawful-evil'), ('neutral-good'), ('neutral-neutral'), ('neutral-evil'), ('chaotic-good'), ('chaotic-neutral'), ('chaotic-evil');

CREATE TABLE creature_types (
	creature_type VARCHAR(32),
    primary key (creature_type)
);

insert into creature_types (creature_type) values ('Aberation'), ('Beast'), ('Celestial'), ('Construct'), ('Dragon'), ('Elemental'), ('Fey'), ('Fiend'), ('Giant'), ('Humanoid'), ('Monstrosity'), ('Ooze'), ('Plant'), ('Undead');

CREATE TABLE creatures (
    entry_id INT(11),
    `type` varchar(32),
    race VARCHAR(32),
    gender VARCHAR(16),
    max_hit_points INT(11),
    average_max_hit_points varchar(32),
    constitution INT(11),
    strength INT(11),
    dexterity INT(11),

    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)
)
