Skip to content

Commit

Permalink
chore(#3): DB 설계 초본 이미지 및 sql
Browse files Browse the repository at this point in the history
  • Loading branch information
memoer committed Jun 10, 2022
1 parent 55c3347 commit 438a988
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 18 deletions.
16 changes: 0 additions & 16 deletions .github/ISSUE_TEMPLATE/chore_request.md

This file was deleted.

2 changes: 0 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@
- Projects 필수
2. 해당 Issue에 대한 PR을 Draft로 등록
- Projects 필수
2. 해당 Issue에 대한 PR을 Draft로 등록
- Project 필수
3. 해당 작업이 모두 완료되면 Draft 제거
4. 리뷰 받기
- 리뷰를 받고 수정해야 할 작업이 있다면, PR Title에 "wip"를 추가하고 진행한다. 이후, 모두 완료되었으면 "wip" 제거
Expand Down
154 changes: 154 additions & 0 deletions src/main/resources/sql/airjnc_1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
CREATE TABLE IF NOT EXISTS `airbnb`.`address` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`code` VARCHAR(10) NOT NULL,
`detail` VARCHAR(45) NOT NULL,

PRIMARY KEY (`id`)
) ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `airbnb`.`user` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`email` VARCHAR(45) NOT NULL,
`password` VARCHAR(45) NOT NULL,
`name` VARCHAR(45) NOT NULL,
`gender` ENUM('MALE', 'FEMALE'),
`birthdate` DATE,
`phone_number` VARCHAR(15),
`is_active` BOOLEAN DEFAULT TRUE,
`created_at` TIMESTAMP,
`updated_at` TIMESTAMP,

`address_id` INT UNSIGNED,

PRIMARY KEY (`id`),
FOREIGN KEY (`address_id`) REFERENCES `airbnb`.`address` (`id`)
)
ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `airbnb`.`room_category` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(15) NOT NULL,

PRIMARY KEY (`id`)
) ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `airbnb`.`room` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`title` VARCHAR(50) NOT NULL,
`description` TEXT NOT NULL,
`type` ENUM('WHOLE', 'PRIVATE', 'SHARED') NOT NULL,
`limit_guests` INT NOT NULL,
`beds` INT NOT NULL,
`bedrooms` INT NOT NULL,
`baths` INT NOT NULL,
`status` ENUM('IN_OPERATION', 'SHUT_DOWN', 'DISABLED') NOT NULL DEFAULT 'SHUT_DOWN',
`check_in` DATETIME NOT NULL,
`check_out` DATETIME NOT NULL,
`smoking_allowed` TINYINT(1) NULL DEFAULT '0',
`pets_allowed` TINYINT(1) NULL DEFAULT '0',
`rule` TEXT NULL DEFAULT NULL,
`created_at` TIMESTAMP,
`updated_at` TIMESTAMP,

`user_id` INT UNSIGNED NOT NULL,
`category_id` INT UNSIGNED NOT NULL,
`address_id` INT UNSIGNED NOT NULL,

PRIMARY KEY (`id`),
FOREIGN KEY (`user_id`) REFERENCES `airbnb`.`user` (`id`),
FOREIGN KEY (`category_id`) REFERENCES `airbnb`.`room_category` (`id`),
FOREIGN KEY (`address_id`) REFERENCES `airbnb`.`address` (`id`)
) ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `airbnb`.`reservation` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`status` ENUM('PENDING', 'CONFIRMED', 'CANCELED') NOT NULL,
`created_at` TIMESTAMP,
`updated_at` TIMESTAMP,
`stay_start_date` DATETIME NOT NULL,
`stay_end_date` DATETIME NOT NULL,
`total_price` INT NOT NULL,

`user_id` INT UNSIGNED NOT NULL,
`room_id` INT UNSIGNED NOT NULL,

PRIMARY KEY (`id`),
FOREIGN KEY (`user_id`) REFERENCES `airbnb`.`user` (`id`),
FOREIGN KEY (`room_id`) REFERENCES `airbnb`.`room` (`id`)
) ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `airbnb`.`room_facility_category` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(10) NOT NULL,

PRIMARY KEY (`id`)
)ENGINE = InnoDB;


CREATE TABLE IF NOT EXISTS `airbnb`.`room_facility` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(20) NOT NULL,
`description` VARCHAR(45) NULL DEFAULT NULL,

`category_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`category_id`) REFERENCES `airbnb`.`room_facility_category` (`id`)
)ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `airbnb`.`room_room_facility` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`room_id` INT UNSIGNED NOT NULL,
`facility_id` INT UNSIGNED NOT NULL,

PRIMARY KEY (`id`),
UNIQUE KEY `room_room_facility_unique` (`room_id`, `facility_id`),
FOREIGN KEY (`room_id`) REFERENCES `airbnb`.`room` (`id`),
FOREIGN KEY (`facility_id`) REFERENCES `airbnb`.`room_facility` (`id`)
) ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `airbnb`.`room_photo` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`url` VARCHAR(255) NOT NULL,
`order` TINYINT UNSIGNED NULL DEFAULT '0',

`room_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`room_id`) REFERENCES `airbnb`.`room` (`id`)
) ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `airbnb`.`room_price` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`price` INT UNSIGNED NOT NULL,

`room_id` INT UNSIGNED NOT NULL,

PRIMARY KEY (`id`),
FOREIGN KEY (`room_id`) REFERENCES `airbnb`.`room` (`id`)
) ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `airbnb`.`room_review` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`content` TEXT NOT NULL,
`price` TINYINT NOT NULL,
`location` TINYINT NOT NULL,
`cleanliness` TINYINT NOT NULL,
`created_at` TIMESTAMP,
`updated_at` TIMESTAMP,

`room_id` INT UNSIGNED NOT NULL,
`user_id` INT UNSIGNED NOT NULL,

PRIMARY KEY (`id`),
UNIQUE INDEX `room_review_unique` (`user_id`, `room_id`),
FOREIGN KEY (`room_id`) REFERENCES `airbnb`.`room` (`id`),
FOREIGN KEY (`user_id`) REFERENCES `airbnb`.`user` (`id`)
)ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `airbnb`.`wish_room` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` INT UNSIGNED NOT NULL,
`room_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`user_id`) REFERENCES `airbnb`.`user` (`id`),
FOREIGN KEY (`room_id`) REFERENCES `airbnb`.`room` (`id`)
)ENGINE = InnoDB;
Binary file added wikiimages/airjnc_1_ERD.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 438a988

Please sign in to comment.