-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathdb_table.sql
More file actions
30 lines (24 loc) · 780 Bytes
/
db_table.sql
File metadata and controls
30 lines (24 loc) · 780 Bytes
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
CREATE DATABASE IF NOT EXISTS `jspDiary`;
USE `jspDiary`;
CREATE TABLE IF NOT EXISTS `diary` (
`diary_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`date_of_diary` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`content` text NOT NULL,
`visibility` bit(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`diary_id`)
);
CREATE TABLE IF NOT EXISTS `user` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(50) NOT NULL,
`last_name` varchar(50) NOT NULL,
`user_name` varchar(100) NOT NULL,
`password` varchar(32) NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `user_name` (`user_name`)
);
CREATE TABLE `user_roles` (
`user_name` varchar(100) NOT NULL,
`role_name` varchar(15) NOT NULL,
PRIMARY KEY (`user_name`,`role_name`)
);