CREATE TABLE `ma_LibraryNaicsApprovedPreferred` (
  `libraryId` int(11) UNSIGNED NOT NULL,
  `naicsCode` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `ma_LibraryNaicsApprovedPreferred`
  ADD PRIMARY KEY (`libraryId`,`naicsCode`),
  ADD KEY `naicsCode` (`naicsCode`);

ALTER TABLE `ma_LibraryNaicsApprovedPreferred`
  ADD CONSTRAINT `ma_LibraryNaicsApprovedPreferred_ibfk_1` FOREIGN KEY (`libraryId`) REFERENCES `ma_Library` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `ma_LibraryNaicsApprovedPreferred_ibfk_2` FOREIGN KEY (`naicsCode`) REFERENCES `ma_Naics` (`id`) ON UPDATE CASCADE;
COMMIT;

CREATE TABLE `ma_LibraryNaicsPendingApprovedPreferred` (
  `libraryId` int(11) UNSIGNED NOT NULL,
  `naicsCode` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `ma_LibraryNaicsPendingApprovedPreferred`
  ADD PRIMARY KEY (`libraryId`,`naicsCode`),
  ADD KEY `naicsCode` (`naicsCode`);

ALTER TABLE `ma_LibraryNaicsPendingApprovedPreferred`
  ADD CONSTRAINT `ma_LibraryNaicsPendingApprovedPreferred_ibfk_1` FOREIGN KEY (`libraryId`) REFERENCES `ma_Library` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `ma_LibraryNaicsPendingApprovedPreferred_ibfk_2` FOREIGN KEY (`naicsCode`) REFERENCES `ma_Naics` (`id`) ON UPDATE CASCADE;
