

CREATE TABLE cfdat_command (
	PRIMARY KEY (script_id, seq),

	script_id	NUMBER(8) NOT NULL REFERENCES cfdat_script,
	seq		NUMBER(6),

	cmd		NUMBER(2),
	dest		NUMBER(3),
	addr		NUMBER(6),
	data		NUMBER(10)
);

CREATE TABLE cfdat_script (
	PRIMARY KEY (script_id),

	script_id	NUMBER(8) NOT NULL UNIQUE,

	name		VARCHAR(100) NOT NULL,
	svn_rel		NUMBER(6) NOT NULL	
);


CREATE TABLE cfdat_config (
	PRIMARY KEY (cfg_id),

	cfg_id		NUMBER(10) UNIQUE NOT NULL,
	
	name		VARCHAR(100) NOT NULL,
	svn_rel		NUMBER(6) NOT NULL
);



CREATE TABLE cfdat_config_scripts (
	PRIMARY KEY (cfg_id,seq),

	cfg_id		NUMBER(10) NOT NULL REFERENCES cfdat_config,
	seq		NUMBER(6) NOT NULL,
	
	script_id	NUMBER(8) NOT NULL REFERENCES cfdat_script,

	restrict_sm	NUMBER(2),
	restrict_layer	NUMBER(1),
	restrict_stack	NUMBER(1)

);
