ALTER TABLE endf_materials ADD mat SMALLINT;

CREATE TABLE endf_covariances (
  cov_key INTEGER,
  lib_key INTEGER,
  format TINYINT,
  content TINYINT,
  mat1 SMALLINT,
  mf1 TINYINT,
  mt1 TINYINT,
  mat2 SMALLINT,
  mf2 TINYINT,
  mt2 TINYINT,
  CONSTRAINT pk_endf_covariances PRIMARY KEY (cov_key),
  CONSTRAINT fk_endf_covariances_lib FOREIGN KEY (lib_key) REFERENCES endf_libraries
);

CREATE TABLE endf_cov_locations (
  cov_key INTEGER,
  file_key INTEGER,
  loc_offset BIGINT,
  loc_length BIGINT,
  CONSTRAINT pk_endf_cov_locations PRIMARY KEY (cov_key),
  CONSTRAINT fk_endf_cov_locations_key FOREIGN KEY (cov_key) REFERENCES endf_covariances,
  CONSTRAINT fk_endf_cov_locations_files FOREIGN KEY (file_key) REFERENCES endf_files
);
