0

/* create table mailing */

CREATE TABLE IF NOT EXISTS mailing(
                            id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
                            addr VARCHAR(255) NOT NULL,
                            domain VARCHAR(255) NOT NULL)ENGINE = InnoDB

/* create table addr_count */

CREATE TABLE IF NOT EXISTS addr_count(
                            id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
                            e_addr VARCHAR(255) NOT NULL,
                            e_domain VARCHAR(255) NOT NULL,
                            count INT NOT NULL,
                            INDEX (e_addr),
                            INDEX (e_domain),
                            FOREIGN KEY (e_addr) REFERENCES mailing (addr) ON DELETE CASCADE ON UPDATE CASCADE,
                            FOREIGN KEY (e_domain) REFERENCES mailing (domain) ON DELETE CASCADE ON UPDATE CASCADE)
                            ENGINE = InnoDB

Could you please help me with this error? Everything seems correct to me but not sure what I am missing!

Ram
  • 575
  • 2
  • 8
  • 18
  • 2
    Both of those columns require an index in the referenced table `mailing`. Instead of creating `INDEX (e_addr), INDEX (e_domain)` in `addr_count` (which is implicit in the `FOREIGN KEY`) create the two indexes instead on `addr` & `domain` in the `mailing` table. – Michael Berkowski Jun 18 '14 at 20:18
  • 2
    Like this: http://sqlfiddle.com/#!2/fe9744 – Michael Berkowski Jun 18 '14 at 20:20

0 Answers0