-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_db.sql
More file actions
114 lines (103 loc) · 4.06 KB
/
init_db.sql
File metadata and controls
114 lines (103 loc) · 4.06 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
-- Database Migration Script for Project Initialization
-- Create tables for the project database
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for categories
-- ----------------------------
CREATE TABLE IF NOT EXISTS `categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of categories
-- ----------------------------
INSERT IGNORE INTO `categories` (`id`, `name`) VALUES (1, 'General');
INSERT IGNORE INTO `categories` (`id`, `name`) VALUES (2, 'Hair Style');
-- ----------------------------
-- Table structure for roles
-- ----------------------------
CREATE TABLE IF NOT EXISTS `roles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`description` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of roles
-- ----------------------------
INSERT IGNORE INTO `roles` (`id`, `name`, `description`) VALUES (1, 'admin', 'Administrator with full access');
INSERT IGNORE INTO `roles` (`id`, `name`, `description`) VALUES (2, 'user', 'Standard user with basic access');
INSERT IGNORE INTO `roles` (`id`, `name`, `description`) VALUES (3, 'moderator', 'Moderator with elevated permissions');
-- ----------------------------
-- Table structure for users
-- ----------------------------
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`role_id` int(11) DEFAULT NULL,
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `email` (`email`),
KEY `role_id` (`role_id`),
CONSTRAINT `users_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Table structure for students
-- ----------------------------
CREATE TABLE IF NOT EXISTS `students` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`email` varchar(255) NOT NULL,
`course` varchar(100) NOT NULL,
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Table structure for gallery
-- ----------------------------
CREATE TABLE IF NOT EXISTS `gallery` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`filename` varchar(255) NOT NULL,
`text` text,
`timestamp` datetime NOT NULL,
`category_id` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
KEY `category_id` (`category_id`),
CONSTRAINT `gallery_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Table structure for word_data
-- ----------------------------
CREATE TABLE IF NOT EXISTS `word_data` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`filename` varchar(255) NOT NULL,
`text_content` text,
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Table structure for word_images
-- ----------------------------
CREATE TABLE IF NOT EXISTS `word_images` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`word_data_id` int(11) NOT NULL,
`image_path` varchar(255) NOT NULL,
`label` varchar(255) DEFAULT NULL,
`category` varchar(100) DEFAULT NULL,
`round_number` int(11) DEFAULT '0',
`audio_path` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `word_data_id` (`word_data_id`),
CONSTRAINT `word_images_ibfk_1` FOREIGN KEY (`word_data_id`) REFERENCES `word_data` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
SET FOREIGN_KEY_CHECKS = 1;