-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary.sql
310 lines (254 loc) · 15.1 KB
/
library.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
-- phpMyAdmin SQL Dump
-- version 4.8.2
-- https://www.phpmyadmin.net/
--
-- 主機: 127.0.0.1
-- 產生時間: 2018 年 11 月 22 日 20:34
-- 伺服器版本: 10.1.34-MariaDB
-- PHP 版本: 7.2.7
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- 資料庫: `library`
--
-- --------------------------------------------------------
--
-- 資料表結構 `book`
--
CREATE TABLE `book` (
`code` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
`author` varchar(20) NOT NULL,
`picture` varchar(50) NOT NULL,
`description` varchar(500) DEFAULT NULL,
`ISBN` int(11) DEFAULT NULL,
`availability` varchar(5) NOT NULL DEFAULT 'true',
`rate` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- 資料表的匯出資料 `book`
--
INSERT INTO `book` (`code`, `name`, `author`, `picture`, `description`, `ISBN`, `availability`, `rate`) VALUES
(1, 'Eng Book', 'Chris Wong', './img/books/B01.jpg', 'I like English. I am never at home on Sundays.Lets all be unique together until we realise we are all the same.\r\nShe advised him to come back at once.\r\n', NULL, 'false', 0),
(2, 'Chinese Book', 'Chris Wong', './img/books/B02.jpg', 'I like Chinese. I am never at home on Sundays.Lets all be unique together until we realise we are all the same.\r\nShe advised him to come back at once.\r\n', NULL, 'false', 0),
(3, 'Maths Book', 'Chris Chan', './img/books/B03.jpg', 'I like Mathematics. I am never at home on Sundays.Lets all be unique together until we realise we are all the same.\r\nShe advised him to come back at once.\r\nThe lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'true', 0),
(4, 'Biology Book', 'Cherry Fung', './img/books/B04.jpg', 'It is a book about Biology. I am never at home on Sundays.Lets all be unique together until we realise we are all the same.\r\nShe advised him to come back at once.\r\nThe lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'true', 0),
(5, 'Eng Book2', 'Chris Wong', './img/books/B05.jpg', 'It is a book about English. I am never at home on Sundays.Lets all be unique together until we realise we are all the same.\r\nShe advised him to come back at once.\r\nThe lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'true', 0),
(6, 'Chinese Book2', 'Chris Wong', './img/books/B06.jpg', 'It is a book about Chinese. I am never at home on Sundays.Lets all be unique together until we realise we are all the same.\r\nShe advised him to come back at once.\r\nThe lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'true', 0),
(7, 'Maths Book2', 'Chris Chan', './img/books/B07.jpg', 'It is a book about Mathematics. I am never at home on Sundays.Lets all be unique together until we realise we are all the same.\r\nShe advised him to come back at once.\r\nThe lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'true', 0),
(8, 'Biology Book2', 'Cherry Fung', './img/books/B08.jpg', 'It is a book about Biology. I am never at home on Sundays.Lets all be unique together until we realise we are all the same.\r\nShe advised him to come back at once.\r\nThe lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'false', 0);
-- --------------------------------------------------------
--
-- 資料表結構 `lend_book`
--
CREATE TABLE `lend_book` (
`email` varchar(50) NOT NULL,
`book_code` int(11) NOT NULL,
`start_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`end_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`late_day` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- 資料表的匯出資料 `lend_book`
--
INSERT INTO `lend_book` (`email`, `book_code`, `start_date`, `end_date`, `late_day`) VALUES
('[email protected]', 1, NULL, NULL, 0),
('[email protected]', 2, NULL, NULL, 0),
('[email protected]', 8, NULL, NULL, 0);
-- --------------------------------------------------------
--
-- 資料表結構 `lend_magazine`
--
CREATE TABLE `lend_magazine` (
`email` varchar(50) NOT NULL,
`magazine_code` int(11) NOT NULL,
`start_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`end_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`late_day` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- 資料表的匯出資料 `lend_magazine`
--
INSERT INTO `lend_magazine` (`email`, `magazine_code`, `start_date`, `end_date`, `late_day`) VALUES
('[email protected]', 1, NULL, NULL, 0);
-- --------------------------------------------------------
--
-- 資料表結構 `lend_software`
--
CREATE TABLE `lend_software` (
`email` varchar(50) NOT NULL,
`software_code` int(11) NOT NULL,
`start_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`end_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`late_day` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- 資料表的匯出資料 `lend_software`
--
INSERT INTO `lend_software` (`email`, `software_code`, `start_date`, `end_date`, `late_day`) VALUES
('[email protected]', 1, NULL, NULL, 0),
('[email protected]', 2, NULL, NULL, 0);
-- --------------------------------------------------------
--
-- 資料表結構 `magazine`
--
CREATE TABLE `magazine` (
`code` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
`company` varchar(20) NOT NULL,
`picture` varchar(50) NOT NULL,
`description` varchar(500) DEFAULT NULL,
`ISBN` int(11) DEFAULT NULL,
`availability` varchar(5) NOT NULL DEFAULT 'true',
`rate` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- 資料表的匯出資料 `magazine`
--
INSERT INTO `magazine` (`code`, `name`, `company`, `picture`, `description`, `ISBN`, `availability`, `rate`) VALUES
(1, 'Eng Magazine', 'ABC News', './img/magazines/M01.jpg', 'It is a magazine about English. I am never at home on Sundays.Lets all be unique together until we realise we are all the same.\r\nShe advised him to come back at once.\r\n', NULL, 'false', 0),
(2, 'Chinese Magazine', 'ABC News', './img/magazines/M02.jpg', 'It is a magazine about Chinese. I am never at home on Sundays.Lets all be unique together until we realise we are all the same.\r\nShe advised him to come back at once.\r\n', NULL, 'true', 0),
(3, 'Maths Magazine', 'ABC News', './img/magazines/M03.jpg', 'It is a magazine about Mathematics. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'true', 0),
(4, 'Biology Magazine', 'ABC News', './img/magazines/M04.jpg', 'It is a magazine about Biology. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'true', 0),
(5, 'Eng Magazine2', 'ABC News', './img/magazines/M05.jpg', 'It is a magazine about English. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'true', 0),
(6, 'Chinese Magazine2', 'ABC News', './img/magazines/M06.jpg', 'It is a magazine about Chinese. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'true', 0),
(7, 'Maths Magazine2', 'ABC News', './img/magazines/M07.jpg', 'It is a magazine about Mathematics. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'true', 0),
(8, 'Biology Magazine2', 'ABC News', './img/magazines/M08.jpg', 'It is a magazine about Biology. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', NULL, 'true', 0);
-- --------------------------------------------------------
--
-- 資料表結構 `software`
--
CREATE TABLE `software` (
`code` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
`company` varchar(20) NOT NULL,
`picture` varchar(50) NOT NULL,
`description` varchar(500) DEFAULT NULL,
`availability` varchar(5) NOT NULL DEFAULT 'true',
`rate` int(11) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- 資料表的匯出資料 `software`
--
INSERT INTO `software` (`code`, `name`, `company`, `picture`, `description`, `availability`, `rate`) VALUES
(1, 'Eng Software', 'ABC Company', './img/software/S01.jpg', 'It is a software about English. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', 'false', 0),
(2, 'Chinese Software', 'ABC Company', './img/software/S02.jpg', 'It is a software about Chinese. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', 'false', 0),
(3, 'Maths Software', 'ABC Company', './img/software/S03.jpg', 'It is a software about Mathematics. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', 'true', 0),
(4, 'Biology Software', 'ABC Company', './img/software/S04.jpg', 'It is a software about Biology. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', 'true', 0),
(5, 'Eng Software2', 'ABC Company', './img/software/S05.jpg', 'It is a software about English. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', 'true', 0),
(6, 'Chinese Software2', 'ABC Company', './img/software/S06.jpg', 'It is a software about Chinese. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', 'true', 0),
(7, 'Maths Software2', 'ABC Company', './img/software/S07.jpg', 'It is a software about Mathematics. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', 'true', 0),
(8, 'Biology Software2', 'ABC Company', './img/software/S08.jpg', 'It is a software about Biology. The lake is a long way from here. He told us a very exciting adventure story. There was no ice cream in the freezer, or did they have money to go to the store. Rock music approaches at high velocity.', 'true', 0);
-- --------------------------------------------------------
--
-- 資料表結構 `user`
--
CREATE TABLE `user` (
`role` varchar(20) NOT NULL,
`name` varchar(25) NOT NULL,
`email` varchar(50) NOT NULL,
`password` int(10) NOT NULL,
`login_count` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- 資料表的匯出資料 `user`
--
INSERT INTO `user` (`role`, `name`, `email`, `password`, `login_count`) VALUES
('non_teacher', 'Peter Kuan', '[email protected]', 123456, 0),
('teacher', 'Ken Li', '[email protected]', 123456, 10),
('student', 'Ng Pui Lam', '[email protected]', 123456, 10),
('alumni', 'Taylor Swift', '[email protected]', 123456, 0),
('alumni', 'Troyel Steve', '[email protected]', 123456, 10),
('non_teacher', 'Marry Sui', '[email protected]', 123456, 10),
('student', 'Terry Fung', '[email protected]', 123456, 0),
('teacher', 'Wong Ton', '[email protected]', 123456, 0);
--
-- 已匯出資料表的索引
--
--
-- 資料表索引 `book`
--
ALTER TABLE `book`
ADD PRIMARY KEY (`code`);
--
-- 資料表索引 `lend_book`
--
ALTER TABLE `lend_book`
ADD PRIMARY KEY (`email`,`book_code`),
ADD KEY `book_code_fk` (`book_code`);
--
-- 資料表索引 `lend_magazine`
--
ALTER TABLE `lend_magazine`
ADD PRIMARY KEY (`email`,`magazine_code`),
ADD KEY `magazine_code_fk` (`magazine_code`);
--
-- 資料表索引 `lend_software`
--
ALTER TABLE `lend_software`
ADD PRIMARY KEY (`email`,`software_code`),
ADD KEY `software_code_fk` (`software_code`);
--
-- 資料表索引 `magazine`
--
ALTER TABLE `magazine`
ADD PRIMARY KEY (`code`);
--
-- 資料表索引 `software`
--
ALTER TABLE `software`
ADD PRIMARY KEY (`code`);
--
-- 資料表索引 `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`email`);
--
-- 在匯出的資料表使用 AUTO_INCREMENT
--
--
-- 使用資料表 AUTO_INCREMENT `book`
--
ALTER TABLE `book`
MODIFY `code` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- 使用資料表 AUTO_INCREMENT `magazine`
--
ALTER TABLE `magazine`
MODIFY `code` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- 使用資料表 AUTO_INCREMENT `software`
--
ALTER TABLE `software`
MODIFY `code` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- 已匯出資料表的限制(Constraint)
--
--
-- 資料表的 Constraints `lend_book`
--
ALTER TABLE `lend_book`
ADD CONSTRAINT `book_code_fk` FOREIGN KEY (`book_code`) REFERENCES `book` (`code`),
ADD CONSTRAINT `book_email_fk` FOREIGN KEY (`email`) REFERENCES `user` (`email`);
--
-- 資料表的 Constraints `lend_magazine`
--
ALTER TABLE `lend_magazine`
ADD CONSTRAINT `magazine_code_fk` FOREIGN KEY (`magazine_code`) REFERENCES `magazine` (`code`),
ADD CONSTRAINT `magazine_email_fk` FOREIGN KEY (`email`) REFERENCES `user` (`email`);
--
-- 資料表的 Constraints `lend_software`
--
ALTER TABLE `lend_software`
ADD CONSTRAINT `software_code_fk` FOREIGN KEY (`software_code`) REFERENCES `software` (`code`),
ADD CONSTRAINT `software_email_fk` FOREIGN KEY (`email`) REFERENCES `user` (`email`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;