CREATE TABLE menus (
  id int PRIMARY KEY,
  descr varchar(50),
  link varchar(255),
  type int NOT NULL,
  pos int NOT NULL,
  parent_id int REFERENCES menus
  
);

CREATE TABLE menu_rights (
	menu_id int REFERENCES menus,
	role_id int REFERENCES user_roles,
	PRIMARY KEY(menu_id, role_id)
);

CREATE SEQUENCE seq_jsp;

CREATE TABLE jsp (
  id int PRIMARY KEY DEFAULT nextval('seq_jsp'),
  descr varchar(255) NOT NULL
);

CREATE TABLE  jsp_roles (
  jsp_id int REFERENCES jsp,
  role_id int REFERENCES user_roles,
  PRIMARY KEY(jsp_id, role_id)
);





