1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS `trips`; CREATE TABLE `trips` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `client_id` int(10) UNSIGNED NOT NULL, `driver_id` int(10) UNSIGNED NOT NULL, `city_id` int(11) NOT NULL, `status` enum('completed','cancelled_by_driver','cancelled_by_client') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `request_at` date NOT NULL, PRIMARY KEY (`id`) USING BTREE, INDEX `client_fk`(`client_id`) USING BTREE, INDEX `driver_fk`(`driver_id`) USING BTREE, CONSTRAINT `client_fk` FOREIGN KEY (`client_id`) REFERENCES `users` (`user_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `driver_fk` FOREIGN KEY (`driver_id`) REFERENCES `users` (`user_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
INSERT INTO `trips` VALUES (1, 1, 10, 1, 'completed', '2013-10-01'); INSERT INTO `trips` VALUES (2, 2, 11, 1, 'cancelled_by_driver', '2013-10-01'); INSERT INTO `trips` VALUES (3, 3, 12, 6, 'completed', '2013-10-01'); INSERT INTO `trips` VALUES (4, 4, 13, 6, 'cancelled_by_client', '2013-10-01'); INSERT INTO `trips` VALUES (5, 1, 10, 1, 'completed', '2013-10-02'); INSERT INTO `trips` VALUES (6, 2, 11, 6, 'completed', '2013-10-02'); INSERT INTO `trips` VALUES (7, 3, 12, 6, 'completed', '2013-10-02'); INSERT INTO `trips` VALUES (8, 2, 12, 12, 'completed', '2013-10-03'); INSERT INTO `trips` VALUES (9, 3, 10, 12, 'completed', '2013-10-03'); INSERT INTO `trips` VALUES (10, 4, 13, 12, 'cancelled_by_driver', '2013-10-03');
SET FOREIGN_KEY_CHECKS = 1;
|