|
|
|
@ -5,8 +5,10 @@
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS `composite_fk` CASCADE; |
|
|
|
|
DROP TABLE IF EXISTS `order_item` CASCADE; |
|
|
|
|
DROP TABLE IF EXISTS `order_item_with_null_fk` CASCADE; |
|
|
|
|
DROP TABLE IF EXISTS `item` CASCADE; |
|
|
|
|
DROP TABLE IF EXISTS `order` CASCADE; |
|
|
|
|
DROP TABLE IF EXISTS `order_with_null_fk` CASCADE; |
|
|
|
|
DROP TABLE IF EXISTS `category` CASCADE; |
|
|
|
|
DROP TABLE IF EXISTS `customer` CASCADE; |
|
|
|
|
DROP TABLE IF EXISTS `profile` CASCADE; |
|
|
|
@ -61,6 +63,14 @@ CREATE TABLE `order` (
|
|
|
|
|
CONSTRAINT `FK_order_customer_id` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`) ON DELETE CASCADE |
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
|
|
|
|
|
|
|
|
|
CREATE TABLE `order_with_null_fk` ( |
|
|
|
|
`id` int(11) NOT NULL AUTO_INCREMENT, |
|
|
|
|
`customer_id` int(11), |
|
|
|
|
`created_at` int(11) NOT NULL, |
|
|
|
|
`total` decimal(10,0) NOT NULL, |
|
|
|
|
PRIMARY KEY (`id`) |
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
|
|
|
|
|
|
|
|
|
CREATE TABLE `order_item` ( |
|
|
|
|
`order_id` int(11) NOT NULL, |
|
|
|
|
`item_id` int(11) NOT NULL, |
|
|
|
@ -72,6 +82,14 @@ CREATE TABLE `order_item` (
|
|
|
|
|
CONSTRAINT `FK_order_item_item_id` FOREIGN KEY (`item_id`) REFERENCES `item` (`id`) ON DELETE CASCADE |
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE `order_item_with_null_fk` ( |
|
|
|
|
`order_id` int(11), |
|
|
|
|
`item_id` int(11), |
|
|
|
|
`quantity` int(11) NOT NULL, |
|
|
|
|
`subtotal` decimal(10,0) NOT NULL |
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
|
|
|
|
|
|
|
|
|
CREATE TABLE `composite_fk` ( |
|
|
|
|
`id` int(11) NOT NULL, |
|
|
|
|
`order_id` int(11) NOT NULL, |
|
|
|
@ -124,6 +142,10 @@ INSERT INTO `order` (customer_id, created_at, total) VALUES (1, 1325282384, 110.
|
|
|
|
|
INSERT INTO `order` (customer_id, created_at, total) VALUES (2, 1325334482, 33.0); |
|
|
|
|
INSERT INTO `order` (customer_id, created_at, total) VALUES (2, 1325502201, 40.0); |
|
|
|
|
|
|
|
|
|
INSERT INTO `order_with_null_fk` (customer_id, created_at, total) VALUES (1, 1325282384, 110.0); |
|
|
|
|
INSERT INTO `order_with_null_fk` (customer_id, created_at, total) VALUES (2, 1325334482, 33.0); |
|
|
|
|
INSERT INTO `order_with_null_fk` (customer_id, created_at, total) VALUES (2, 1325502201, 40.0); |
|
|
|
|
|
|
|
|
|
INSERT INTO `order_item` (order_id, item_id, quantity, subtotal) VALUES (1, 1, 1, 30.0); |
|
|
|
|
INSERT INTO `order_item` (order_id, item_id, quantity, subtotal) VALUES (1, 2, 2, 40.0); |
|
|
|
|
INSERT INTO `order_item` (order_id, item_id, quantity, subtotal) VALUES (2, 4, 1, 10.0); |
|
|
|
@ -131,6 +153,13 @@ INSERT INTO `order_item` (order_id, item_id, quantity, subtotal) VALUES (2, 5, 1
|
|
|
|
|
INSERT INTO `order_item` (order_id, item_id, quantity, subtotal) VALUES (2, 3, 1, 8.0); |
|
|
|
|
INSERT INTO `order_item` (order_id, item_id, quantity, subtotal) VALUES (3, 2, 1, 40.0); |
|
|
|
|
|
|
|
|
|
INSERT INTO `order_item_with_null_fk` (order_id, item_id, quantity, subtotal) VALUES (1, 1, 1, 30.0); |
|
|
|
|
INSERT INTO `order_item_with_null_fk` (order_id, item_id, quantity, subtotal) VALUES (1, 2, 2, 40.0); |
|
|
|
|
INSERT INTO `order_item_with_null_fk` (order_id, item_id, quantity, subtotal) VALUES (2, 4, 1, 10.0); |
|
|
|
|
INSERT INTO `order_item_with_null_fk` (order_id, item_id, quantity, subtotal) VALUES (2, 5, 1, 15.0); |
|
|
|
|
INSERT INTO `order_item_with_null_fk` (order_id, item_id, quantity, subtotal) VALUES (2, 3, 1, 8.0); |
|
|
|
|
INSERT INTO `order_item_with_null_fk` (order_id, item_id, quantity, subtotal) VALUES (3, 2, 1, 40.0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* (MySQL-)Database Schema for validator tests |
|
|
|
|