- INDEX `product_id` (`product_id`),
- INDEX `customer_product` (`customer_id`,`product_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Customer orders';
+ INDEX (`order_id`),
+ INDEX (`product_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Ordered items';
+
+CREATE TABLE `orders` (
+ `id` bigint(20) unsigned NOT NULL COMMENT 'Primary key',
+ `customer_id` bigint(20) unsigned NOT NULL COMMENT 'Table reference customer',
+ `access_key` varchar(100) NULL DEFAULT NULL COMMENT 'Access key to receipt',
+ `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Order created',
+ PRIMARY KEY (`id`),
+ INDEX (`customer_id`),
+ UNIQUE (`access_key`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Customer orders';
+
+CREATE TABLE `products` (
+ `id` bigint(20) unsigned NOT NULL COMMENT 'Primary key',
+ `category` bigint(20) unsigned DEFAULT NULL COMMENT 'Category id',
+ `title` varchar(100) NOT NULL COMMENT 'Title of product',
+ `price` decimal(20,2) unsigned NOT NULL COMMENT 'Product price',
+ `available` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether product is available',
+ PRIMARY KEY (`id`),
+ INDEX (`category`)
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COMMENT='Products';