DROP TABLE IF EXISTS `table_parent`;
CREATE TABLE `table_parent`
(
   `id` INT(11) NOT NULL AUTO_INCREMENT,
	PRIMARY KEY (`id`)
)
ENGINE=MYISAM;

DROP TABLE IF EXISTS `table_child`;
CREATE TABLE `table_child`
(
   `id` INT(11) NOT NULL AUTO_INCREMENT,
	`parent_id` INT(11) NOT NULL,
	`value` SMALLINT(6) NOT NULL,
	PRIMARY KEY (`id`),
	INDEX `parent_id` (`parent_id`),
	INDEX `value` (`value`)
)
ENGINE=MYISAM;

INSERT INTO `table_parent` VALUES (1), (2);

DROP PROCEDURE IF EXISTS fill_tables;

delimiter ;;

CREATE PROCEDURE fill_tables()
BEGIN
   DECLARE i int DEFAULT 0;
   WHILE i <= 1000 DO
      INSERT INTO `table_child` (`id`, `parent_id`, `value`) VALUES (0, 1, i);
      INSERT INTO `table_child` (`id`, `parent_id`, `value`) VALUES (0, 2, i);
      SET i = i + 1;
   END WHILE;
END;;

delimiter ;

CALL fill_tables();
