CREATE TABLE "Entity" ( "Id" int, "Name" varchar(255), "TypeId" int, FOREIGN KEY("TypeId") REFERENCES "EntityType" ("Id") ); CREATE TABLE "State" ( "Id" int, "Name" varchar(255), "EntityTypeId" int, FOREIGN KEY("EntityTypeId") REFERENCES "EntityType" ("Id") ); CREATE TABLE "EntityType" ( "Id" int PRIMARY KEY, "Name" varchar(255) ); CREATE TABLE "StartState" ( "StateId" int PRIMARY KEY, FOREIGN KEY("StateId") REFERENCES "State" ("Id") ); CREATE TABLE "DecisionState" ( "StateId" int PRIMARY KEY, "TrueStateId" int, "FalseStateId" int, "DecisionExpression" varchar(255), FOREIGN KEY("StateId") REFERENCES "State" ("Id"), FOREIGN KEY("TrueStateId") REFERENCES "State" ("Id"), FOREIGN KEY("FalseStateId") REFERENCES "State" ("Id") ); CREATE TABLE "SimpleState" ( "StateId" int PRIMARY KEY, "NextStateId" int, FOREIGN KEY("StateId") REFERENCES "State" ("Id"), FOREIGN KEY("NextStateId") REFERENCES "State" ("Id") ); CREATE TABLE "LifePath" ( "Id" int PRIMARY KEY, "EntityId" int, "StateId" int, "ParentStateId" int, FOREIGN KEY("EntityId") REFERENCES "Entity" ("Id"), FOREIGN KEY("StateId") REFERENCES "State" ("Id"), FOREIGN KEY("ParentStateId") REFERENCES "LifePath" ("Id") );