-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sql
37 lines (32 loc) · 825 Bytes
/
script.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
CREATE DATABASE IF NOT EXISTS taskapp;
USE taskapp;
CREATE TABLE users (
id INT AUTO_INCREMENT,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE tasks (
id INT AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
description TEXT,
dueDate DATE,
category VARCHAR(255),
completed BOOLEAN DEFAULT FALSE,
userId INT,
PRIMARY KEY (id),
FOREIGN KEY (userId) REFERENCES users(id)
);
DELIMITER $$
CREATE PROCEDURE insert_task(
IN title VARCHAR(255),
IN description TEXT,
IN dueDate DATE,
IN category VARCHAR(255),
IN completed BOOLEAN,
IN userId INT)
BEGIN
INSERT INTO tasks (title, description, dueDate, category, completed, userId)
VALUES (title, description, dueDate, category, completed, userId);
END$$
DELIMITER ;