text: 
  -- triggers
  
  CREATE TABLE IF NOT EXISTS triggers (
  	id INTEGER PRIMARY KEY AUTOINCREMENT,
  	code VARCHAR(20) UNIQUE NOT NULL,
  	name VARCHAR(100) NOT NULL
  );
  
  -- scenarios
  
  CREATE TABLE IF NOT EXISTS scenarios (
  
  	id INTEGER PRIMARY KEY AUTOINCREMENT,
  	name VARCHAR(100) NOT NULL,
  	active INT(1) NOT NULL DEFAULT 0,
  
  	id_start INTEGER DEFAULT NULL,
  	FOREIGN KEY (id_start) REFERENCES junctions(id) ON DELETE SET NULL ON UPDATE CASCADE
  
  );
  
  -- scenariostriggers
  
  CREATE TABLE IF NOT EXISTS scenariostriggers (
  
  	id_scenario INTEGER NOT NULL,
  	id_trigger INTEGER NOT NULL,
  
  	PRIMARY KEY (id_scenario, id_trigger),
  	FOREIGN KEY (id_scenario) REFERENCES scenarios(id) ON DELETE CASCADE ON UPDATE CASCADE,
  	FOREIGN KEY (id_trigger) REFERENCES triggers(id) ON DELETE CASCADE ON UPDATE CASCADE
  
  );
  
  -- actions
  
  CREATE TABLE IF NOT EXISTS actionstypes (
  	id INTEGER PRIMARY KEY AUTOINCREMENT,
  	code VARCHAR(20) UNIQUE NOT NULL,
  	name VARCHAR(100) NOT NULL
  );
  
  CREATE TABLE IF NOT EXISTS actions (
  
  	id INTEGER PRIMARY KEY AUTOINCREMENT,
  	name VARCHAR(100) NOT NULL,
  	params VARCHAR(250) NOT NULL,
  
  	id_after INTEGER DEFAULT NULL,
  	id_type INTEGER NOT NULL,
  
  	FOREIGN KEY (id_after) REFERENCES junctions(id) ON DELETE SET NULL ON UPDATE CASCADE,
  	FOREIGN KEY (id_type) REFERENCES actionstypes(id) ON DELETE CASCADE ON UPDATE CASCADE
  
  );
  
  -- actionstriggers
  
  CREATE TABLE IF NOT EXISTS actionstriggers (
  
  	id_action INTEGER NOT NULL,
  	id_trigger INTEGER NOT NULL,
  
  	PRIMARY KEY (id_action, id_trigger),
  	FOREIGN KEY (id_action) REFERENCES actions(id) ON DELETE CASCADE ON UPDATE CASCADE,
  	FOREIGN KEY (id_trigger) REFERENCES triggers(id) ON DELETE CASCADE ON UPDATE CASCADE
  
  );
  
  -- conditions
  
  CREATE TABLE IF NOT EXISTS conditionstypes (
  	id INTEGER PRIMARY KEY AUTOINCREMENT,
  	code VARCHAR(20) UNIQUE NOT NULL,
  	name VARCHAR(100) NOT NULL
  );
  
  CREATE TABLE IF NOT EXISTS conditions (
  
  	id INTEGER PRIMARY KEY AUTOINCREMENT,
  	name VARCHAR(100) NOT NULL,
  	datavalue VARCHAR(100) NOT NULL,
  
  	id_onyes INTEGER DEFAULT NULL,
  	id_onno INTEGER DEFAULT NULL,
  	id_type INTEGER NOT NULL,
  
  	FOREIGN KEY (id_onyes) REFERENCES junctions(id) ON DELETE SET NULL ON UPDATE CASCADE,
  	FOREIGN KEY (id_onno) REFERENCES junctions(id) ON DELETE SET NULL ON UPDATE CASCADE,
  	FOREIGN KEY (id_type) REFERENCES conditionstypes(id) ON DELETE CASCADE ON UPDATE CASCADE
  
  );
  
  -- junctions
  
  CREATE TABLE IF NOT EXISTS junctions (
  
  	id INTEGER PRIMARY KEY AUTOINCREMENT,
  
  	id_action INTEGER DEFAULT NULL,
  	id_condition INTEGER DEFAULT NULL,
  	
  	FOREIGN KEY (id_action) REFERENCES actions(id) ON DELETE CASCADE ON UPDATE CASCADE,
  	FOREIGN KEY (id_condition) REFERENCES conditions(id) ON DELETE CASCADE ON UPDATE CASCADE
  
  );
  