
CREATE DATABASE IF NOT EXISTS `ma_tests` /*!40100 DEFAULT CHARACTER SET utf8 */;
CREATE DATABASE IF NOT EXISTS `ma_tests2` /*!40100 DEFAULT CHARACTER SET utf8 */;

DROP TABLE IF EXISTS `ma_tests`.`r`;
DROP TABLE IF EXISTS `ma_tests`.`f`;
DROP TABLE IF EXISTS `ma_tests2`.`r2`;


CREATE TABLE `ma_tests`.`r` (`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `ma_tests2`.`r2` (`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `ma_tests`.`f` (`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, 
	`rid` INTEGER UNSIGNED NOT NULL,  
	`r2id` INTEGER UNSIGNED NOT NULL,  
	PRIMARY KEY(`id`),  
	CONSTRAINT `FK_f_1` FOREIGN KEY `FK_f_1` (`rid`)    REFERENCES `r` (`id`), 
	CONSTRAINT `FK_f_2` FOREIGN KEY `FK_f_2` (`r2id`)    REFERENCES `ma_tests2`.`r2` (`id`)
) ENGINE = InnoDB;
