-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.sql
44 lines (37 loc) · 1.48 KB
/
db.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `tasklist` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `tasklist` ;
-- -----------------------------------------------------
-- Table `tasklist`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tasklist`.`user` (
`user_id` INT NOT NULL AUTO_INCREMENT ,
`username` VARCHAR(14) NOT NULL ,
`password` VARCHAR(32) NOT NULL ,
`created` DATETIME NOT NULL ,
`last_login` DATETIME NOT NULL ,
PRIMARY KEY (`user_id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `tasklist`.`task`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tasklist`.`task` (
`task_id` INT NOT NULL AUTO_INCREMENT ,
`description` TEXT NOT NULL ,
`priority` INT NULL COMMENT '1-Low/2-Medium/3-High' ,
`due_date` DATE NULL ,
`completed` TINYINT NOT NULL DEFAULT 0 COMMENT '0-Not Completed/1-Completed' ,
`user_id` INT NOT NULL ,
PRIMARY KEY (`task_id`) ,
INDEX `fk_task_user` (`user_id` ASC) ,
CONSTRAINT `fk_task_user`
FOREIGN KEY (`user_id` )
REFERENCES `tasklist`.`user` (`user_id` )
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;