category, board 테이블 생성(PK / FK)

권원중·2023년 5월 3일
0

구디아카데미

목록 보기
8/23

1. 관계데이터베이스 테이블 키컬럼

1) 기본키

https://ko.wikipedia.org/wiki/%EA%B8%B0%EB%B3%B8_%ED%82%A4

2) 외래키

https://ko.wikipedia.org/wiki/%EC%99%B8%EB%9E%98_%ED%82%A4

2. 테이블 생성

local테이블

INSERT INTO local(createdate, local_name, updatedate)
VALUES(NOW(), '부산', NOW());


board 테이블

CREATE TABLE `board` (
	`board_no` INT(11) NOT NULL AUTO_INCREMENT,
	`local_name` VARCHAR(50) NOT NULL COLLATE 'utf8_general_ci',
	`board_title` VARCHAR(200) NOT NULL COLLATE 'utf8_general_ci',
	`board_content` TEXT NOT NULL COLLATE 'utf8_general_ci',
	`member_id` VARCHAR(50) NOT NULL COLLATE 'utf8_general_ci',
	`createdate` DATETIME NOT NULL,
	`updatedate` DATETIME NOT NULL,
	PRIMARY KEY (`board_no`) USING BTREE,
	INDEX `FK__local` (`local_name`) USING BTREE,
	INDEX `FK__member` (`member_id`) USING BTREE,
	CONSTRAINT `FK__local` FOREIGN KEY (`local_name`) REFERENCES `userboard`.`local` (`local_name`) ON UPDATE NO ACTION ON DELETE NO ACTION,
	CONSTRAINT `FK__member` FOREIGN KEY (`member_id`) REFERENCES `userboard`.`member` (`member_id`) ON UPDATE NO ACTION ON DELETE NO ACTION
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
;


borad 테이블 데이터 입력

0개의 댓글