Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 7th, 2013  |  syntax: None  |  size: 4.74 KB  |  views: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  2. SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  3. SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
  4.  
  5. CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
  6. USE `mydb` ;
  7.  
  8. -- -----------------------------------------------------
  9. -- Table `mydb`.`items`
  10. -- -----------------------------------------------------
  11. CREATE  TABLE IF NOT EXISTS `mydb`.`items` (
  12.   `id` INT(10) NOT NULL AUTO_INCREMENT ,
  13.   `name` VARCHAR(255) NOT NULL ,
  14.   `slug` VARCHAR(255) NOT NULL ,
  15.   `thumb` VARCHAR(255) NOT NULL ,
  16.   PRIMARY KEY (`id`) )
  17. ENGINE = InnoDB;
  18.  
  19.  
  20. -- -----------------------------------------------------
  21. -- Table `mydb`.`categories`
  22. -- -----------------------------------------------------
  23. CREATE  TABLE IF NOT EXISTS `mydb`.`categories` (
  24.   `id` INT(10) NOT NULL AUTO_INCREMENT ,
  25.   `name` VARCHAR(255) NOT NULL ,
  26.   `slug` VARCHAR(255) NOT NULL ,
  27.   `created_at` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' ,
  28.   PRIMARY KEY (`id`) )
  29. ENGINE = InnoDB;
  30.  
  31.  
  32. -- -----------------------------------------------------
  33. -- Table `mydb`.`items_categories`
  34. -- -----------------------------------------------------
  35. CREATE  TABLE IF NOT EXISTS `mydb`.`items_categories` (
  36.   `items_id` INT NOT NULL ,
  37.   `categories_id` INT NOT NULL ,
  38.   PRIMARY KEY (`items_id`, `categories_id`) ,
  39.   INDEX `fk_items_has_categories_categories1_idx` (`categories_id` ASC) ,
  40.   INDEX `fk_items_has_categories_items_idx` (`items_id` ASC) ,
  41.   CONSTRAINT `fk_items_has_categories_items`
  42.     FOREIGN KEY (`items_id` )
  43.     REFERENCES `mydb`.`items` (`id` )
  44.     ON DELETE NO ACTION
  45.     ON UPDATE NO ACTION,
  46.   CONSTRAINT `fk_items_has_categories_categories1`
  47.     FOREIGN KEY (`categories_id` )
  48.     REFERENCES `mydb`.`categories` (`id` )
  49.     ON DELETE NO ACTION
  50.     ON UPDATE NO ACTION)
  51. ENGINE = InnoDB;
  52.  
  53.  
  54.  
  55. SET SQL_MODE=@OLD_SQL_MODE;
  56. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  57. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  58.  
  59. -- -----------------------------------------------------
  60. -- Data for table `mydb`.`items`
  61. -- -----------------------------------------------------
  62. START TRANSACTION;
  63. USE `mydb`;
  64. INSERT INTO `mydb`.`items` (`id`, `name`, `slug`, `thumb`) VALUES (1, 'Real Madrid', 'rmcf', NULL);
  65. INSERT INTO `mydb`.`items` (`id`, `name`, `slug`, `thumb`) VALUES (2, 'Barcelona', 'barcelona', NULL);
  66. INSERT INTO `mydb`.`items` (`id`, `name`, `slug`, `thumb`) VALUES (3, 'Sevilla', 'sevillacf', NULL);
  67. INSERT INTO `mydb`.`items` (`id`, `name`, `slug`, `thumb`) VALUES (4, 'Internazionale de Millano', 'inter', NULL);
  68. INSERT INTO `mydb`.`items` (`id`, `name`, `slug`, `thumb`) VALUES (5, 'Chelsea', 'chelsea', NULL);
  69. INSERT INTO `mydb`.`items` (`id`, `name`, `slug`, `thumb`) VALUES (6, 'Manchester United', 'manutd', NULL);
  70. INSERT INTO `mydb`.`items` (`id`, `name`, `slug`, `thumb`) VALUES (7, 'Lazio', 'lazio', NULL);
  71.  
  72. COMMIT;
  73.  
  74. -- -----------------------------------------------------
  75. -- Data for table `mydb`.`categories`
  76. -- -----------------------------------------------------
  77. START TRANSACTION;
  78. USE `mydb`;
  79. INSERT INTO `mydb`.`categories` (`id`, `name`, `slug`, `created_at`) VALUES (1, 'Liga de Futbol Profesional', 'lfp', '2013-01-01 00:00:00');
  80. INSERT INTO `mydb`.`categories` (`id`, `name`, `slug`, `created_at`) VALUES (2, 'Calcio', 'calcio', '2013-01-02 00:00:00');
  81. INSERT INTO `mydb`.`categories` (`id`, `name`, `slug`, `created_at`) VALUES (3, 'Premier League', 'pl', '2013-01-03 00:00:00');
  82. INSERT INTO `mydb`.`categories` (`id`, `name`, `slug`, `created_at`) VALUES (4, 'UEFA Champions League', 'UCL', '2013-01-04 00:00:00');
  83.  
  84. COMMIT;
  85.  
  86. -- -----------------------------------------------------
  87. -- Data for table `mydb`.`items_categories`
  88. -- -----------------------------------------------------
  89. START TRANSACTION;
  90. USE `mydb`;
  91. INSERT INTO `mydb`.`items_categories` (`items_id`, `categories_id`) VALUES (1, 1);
  92. INSERT INTO `mydb`.`items_categories` (`items_id`, `categories_id`) VALUES (2, 1);
  93. INSERT INTO `mydb`.`items_categories` (`items_id`, `categories_id`) VALUES (4, 2);
  94. INSERT INTO `mydb`.`items_categories` (`items_id`, `categories_id`) VALUES (3, 1);
  95. INSERT INTO `mydb`.`items_categories` (`items_id`, `categories_id`) VALUES (5, 3);
  96. INSERT INTO `mydb`.`items_categories` (`items_id`, `categories_id`) VALUES (6, 3);
  97. INSERT INTO `mydb`.`items_categories` (`items_id`, `categories_id`) VALUES (7, 2);
  98. INSERT INTO `mydb`.`items_categories` (`items_id`, `categories_id`) VALUES (7, 4);
  99. INSERT INTO `mydb`.`items_categories` (`items_id`, `categories_id`) VALUES (1, 4);
  100. INSERT INTO `mydb`.`items_categories` (`items_id`, `categories_id`) VALUES (6, 4);
  101. INSERT INTO `mydb`.`items_categories` (`items_id`, `categories_id`) VALUES (2, 4);
  102.  
  103. COMMIT;
clone this paste RAW Paste Data