Solusinya :
suplemen
dan suplemen_terdata
.suplemen
.CREATE TABLE suplemen (
id int(11) NOT NULL AUTO_INCREMENT,
config_id int(11) DEFAULT NULL,
nama varchar(100) DEFAULT NULL,
slug varchar(255) DEFAULT NULL,
sasaran tinyint(4) DEFAULT NULL,
keterangan varchar(300) DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY slug_config (config_id,slug),
CONSTRAINT suplemen_config_fk FOREIGN KEY (config_id) REFERENCES config (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
suplemen_terdata
.CREATE TABLE suplemen_terdata (
id int(11) NOT NULL AUTO_INCREMENT,
config_id int(11) DEFAULT NULL,
id_suplemen int(11) DEFAULT NULL,
id_terdata varchar(20) DEFAULT NULL,
sasaran tinyint(4) DEFAULT NULL,
keterangan varchar(100) DEFAULT NULL,
PRIMARY KEY (id),
KEY id_suplemen (id_suplemen),
KEY suplemen_terdata_config_fk (config_id),
CONSTRAINT suplemen_terdata_config_fk FOREIGN KEY (config_id) REFERENCES config (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT suplemen_terdata_suplemen_fk FOREIGN KEY (id_suplemen) REFERENCES suplemen (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
data suplemen
dari SQL
data suplemen_terdata
dari SQL