-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add foreign key constraint into tables. issue: #7
- Loading branch information
1 parent
e6ce720
commit ab1ad22
Showing
1 changed file
with
40 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,59 @@ | ||
CREATE TABLE IF NOT EXISTS `section` | ||
( | ||
id BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
CREATE TABLE IF NOT EXISTS `section` ( | ||
`id` BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
`name` VARCHAR(50) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS category | ||
( | ||
id BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
CREATE TABLE IF NOT EXISTS category ( | ||
`id` BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
`name` VARCHAR(50) | ||
); | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS item | ||
( | ||
id BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
section BIGINT, | ||
category BIGINT, | ||
alt VARCHAR(50), | ||
top_image VARCHAR(65536), | ||
title VARCHAR(50), | ||
description VARCHAR(500), | ||
n_price DECIMAL, | ||
s_price DECIMAL, | ||
delivery_fee DECIMAL, | ||
stock int | ||
CREATE TABLE IF NOT EXISTS item ( | ||
`id` BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
`section` BIGINT, | ||
`category` BIGINT, | ||
`alt` VARCHAR(50), | ||
`top_image` VARCHAR(255), | ||
`title` VARCHAR(50), | ||
`description` VARCHAR(500), | ||
`n_price` DECIMAL, | ||
`s_price` DECIMAL, | ||
`delivery_fee` DECIMAL, | ||
`stock` int, | ||
CONSTRAINT item_section_foreign_key FOREIGN KEY (`section`) REFERENCES `section`(id), | ||
CONSTRAINT item_category_foreign_key FOREIGN KEY (`category`) REFERENCES `category`(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS detail_section | ||
( | ||
item BIGINT, | ||
item_key INT, | ||
url VARCHAR(65536) | ||
CREATE TABLE IF NOT EXISTS detail_section ( | ||
`item` BIGINT, | ||
`item_key` INT, | ||
`url` VARCHAR(255), | ||
CONSTRAINT detail_section_item_foreign_key FOREIGN KEY (`item`) REFERENCES `item`(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS thumb_image | ||
( | ||
item BIGINT, | ||
item_key INT, | ||
url VARCHAR(65536) | ||
CREATE TABLE IF NOT EXISTS thumb_image ( | ||
`item` BIGINT, | ||
`item_key` INT, | ||
`url` VARCHAR(255), | ||
CONSTRAINT thumb_image_item_foreign_key FOREIGN KEY (`item`) REFERENCES `item`(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS badge ( | ||
item BIGINT, | ||
badge_type CHAR(10) | ||
`item` BIGINT, | ||
`badge_type` CHAR(10), | ||
CONSTRAINT badge_item_foreign_key FOREIGN KEY (`item`) REFERENCES `item`(id) | ||
); | ||
|
||
|
||
CREATE TABLE IF NOT EXISTS delivery_type | ||
( | ||
item BIGINT, | ||
delivery_type_name CHAR(10) | ||
CREATE TABLE IF NOT EXISTS delivery_type ( | ||
`item` BIGINT, | ||
`delivery_type_name` CHAR(10), | ||
CONSTRAINT delivery_type_item_foreign_key FOREIGN KEY (`item`) REFERENCES `item`(id) | ||
); | ||
|
||
|
||
CREATE TABLE IF NOT EXISTS delivery_day | ||
( | ||
item BIGINT, | ||
`the_day_of_week` CHAR(3) | ||
CREATE TABLE IF NOT EXISTS delivery_day ( | ||
`item` BIGINT, | ||
`the_day_of_week` CHAR(3), | ||
CONSTRAINT delivery_day_item_foreign_key FOREIGN KEY (`item`) REFERENCES `item`(id) | ||
); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|