-- CREATE LINK "smd__partner_cms__tag_partnerID_partnerID" -----
ALTER TABLE `cms__tag`
    ADD CONSTRAINT `smd__partner_cms__tag_partnerID_partnerID` FOREIGN KEY ( `partnerID` )
        REFERENCES `smd__partner`( `partnerID` )
        ON DELETE Cascade
        ON UPDATE Cascade;
-- -------------------------------------------------------------

DELETE from smd__media_has_categories where categoryID not in (select categoryID from smd__category);

-- CREATE LINK "smd__category_smd__category_categoryID_categoryID"
ALTER TABLE `smd__media_has_categories`
    ADD CONSTRAINT `smd__category_smd__category_categoryID_categoryID` FOREIGN KEY ( `categoryID` )
        REFERENCES `smd__category`( `categoryID` )
        ON DELETE Cascade
        ON UPDATE Cascade;
-- -------------------------------------------------------------