From: Roland Haeder Date: Wed, 19 Aug 2015 11:39:00 +0000 (+0200) Subject: Simplified it more X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9509b35f096d8e9327a5d4e4e8390d08d8cf3410;p=pizzaservice-war.git Simplified it more Signed-off-by:Roland Häder --- diff --git a/install/install.sql b/install/install.sql index be0f194b..2f74a73d 100644 --- a/install/install.sql +++ b/install/install.sql @@ -1,13 +1,15 @@ DROP TABLE IF EXISTS `category`; CREATE TABLE IF NOT EXISTS `category` ( - `id` bigint(20) unsigned NOT NULL COMMENT 'Primary key', +`id` bigint(20) unsigned NOT NULL COMMENT 'Primary key', `title` varchar(255) NOT NULL COMMENT 'Category title', - `parent` bigint(20) unsigned DEFAULT NULL COMMENT 'Parent category' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Categories'; + `parent` bigint(20) unsigned DEFAULT NULL COMMENT 'Parent category', + PRIMARY KEY (`id`), + INDEX `parent` (`parent`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Categories' ; DROP TABLE IF EXISTS `contacts`; CREATE TABLE IF NOT EXISTS `contacts` ( - `id` bigint(20) unsigned NOT NULL COMMENT 'Primary key', +`id` bigint(20) unsigned NOT NULL COMMENT 'Primary key', `own_contact` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether own contact', `gender` varchar(10) NOT NULL DEFAULT 'UNKNOWN' COMMENT 'Gender', `first_name` varchar(100) NOT NULL COMMENT 'First name', @@ -25,32 +27,26 @@ CREATE TABLE IF NOT EXISTS `contacts` ( `birthday` date DEFAULT NULL COMMENT 'Birth day', `comment` tinytext NOT NULL COMMENT 'Comment', `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Entry created', - `updated` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Contacts data' ; + `updated` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Contacts data' ; DROP TABLE IF EXISTS `products`; CREATE TABLE IF NOT EXISTS `products` ( - `id` bigint(20) unsigned NOT NULL COMMENT 'Primary key', +`id` bigint(20) unsigned NOT NULL COMMENT 'Primary key', `category` bigint(20) unsigned DEFAULT NULL COMMENT 'Category id', `title` varchar(255) 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' + `available` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether product is available', + PRIMARY KEY (`id`), + INDEX `category` (`category`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Products' ; - -ALTER TABLE `category` - ADD PRIMARY KEY (`id`), ADD KEY `parent` (`parent`); - -ALTER TABLE `contacts` - ADD PRIMARY KEY (`id`); - -ALTER TABLE `products` - ADD PRIMARY KEY (`id`), ADD KEY `category` (`category`); - - ALTER TABLE `category` MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key'; + ALTER TABLE `contacts` MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key'; + ALTER TABLE `products` MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key';