Fix DDL.sql

This commit is contained in:
Augusto Gunsch 2022-07-29 12:15:14 +02:00
parent b09e8fff28
commit b9bf831001
1 changed files with 6 additions and 5 deletions

View File

@ -1,3 +1,5 @@
DROP DATABASE IF EXISTS `products`;
CREATE DATABASE `products`; CREATE DATABASE `products`;
USE `products`; USE `products`;
@ -9,7 +11,7 @@ CREATE TABLE `product` (
`sku` varchar(100) NOT NULL, `sku` varchar(100) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `sku` (`sku`) UNIQUE KEY `sku` (`sku`)
) );
CREATE TABLE `book` ( CREATE TABLE `book` (
`id` int unsigned NOT NULL AUTO_INCREMENT, `id` int unsigned NOT NULL AUTO_INCREMENT,
@ -18,7 +20,7 @@ CREATE TABLE `book` (
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `book_UN` (`product_id`), UNIQUE KEY `book_UN` (`product_id`),
CONSTRAINT `book_FK` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) CONSTRAINT `book_FK` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`)
) );
CREATE TABLE `dvd` ( CREATE TABLE `dvd` (
`id` int unsigned NOT NULL AUTO_INCREMENT, `id` int unsigned NOT NULL AUTO_INCREMENT,
@ -27,7 +29,7 @@ CREATE TABLE `dvd` (
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `dvd_UN` (`product_id`), UNIQUE KEY `dvd_UN` (`product_id`),
CONSTRAINT `dvd_FK` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) CONSTRAINT `dvd_FK` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`)
) );
CREATE TABLE `furniture` ( CREATE TABLE `furniture` (
`id` int unsigned NOT NULL AUTO_INCREMENT, `id` int unsigned NOT NULL AUTO_INCREMENT,
@ -38,5 +40,4 @@ CREATE TABLE `furniture` (
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `furniture_UN` (`product_id`), UNIQUE KEY `furniture_UN` (`product_id`),
CONSTRAINT `furniture_FK` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) CONSTRAINT `furniture_FK` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`)
) );