create table ad_menu (
	ad_menu_id character varying(32) NOT NULL,
	ad_process_id character varying(32),
	action character varying(60),
	CONSTRAINT ad_menu_key PRIMARY KEY (ad_menu_id),
	CONSTRAINT ad_menu_ad_process FOREIGN KEY (ad_process_id)
		REFERENCES public.ad_process (ad_process_id) MATCH SIMPLE
);

create table ad_model_object (
  ad_model_object_id character varying(32) NOT NULL,
  action character varying(60),
  ad_process_id character varying(32),
  CONSTRAINT ad_model_object_key PRIMARY KEY (ad_model_object_id)
);

create table ad_process (
	ad_process_id character varying(32) NOT NULL,
	CONSTRAINT ad_process_key PRIMARY KEY (ad_process_id)
);

SELECT 1
FROM ad_model_object mo
LEFT JOIN ad_menu m ON mo.ad_process_id = m.ad_process_id
AND mo.action IN ('P', 'R');


