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 FOREIGN KEY("StateId") REFERENCES "State" ("Id"), "TrueStateId" int FOREIGN KEY("TrueStateId") REFERENCES "State" ("Id"), "FalseStateId" int FOREIGN KEY("FalseStateId") REFERENCES "State" ("Id"), "DecisionExpression" varchar(255) ); CREATE TABLE "SimpleState" ( "StateId" int PRIMARY KEY FOREIGN KEY("StateId") REFERENCES "State" ("Id"), "NextStateId" int FOREIGN KEY("NextStateId") REFERENCES "State" ("Id") ); CREATE TABLE "LifePath" ( "Id" int PRIMARY KEY, "EntityId" int FOREIGN KEY("EntityId") REFERENCES "Entity" ("Id"), "StateId" int FOREIGN KEY("StateId") REFERENCES "State" ("Id"), "ParentStateId" int FOREIGN KEY("ParentStateId") REFERENCES "LifePath" ("Id") );