forked from arenfro1987/SEproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.sql
121 lines (91 loc) · 3.59 KB
/
database.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
use SE
-- DROP TABLE IF EXISTS contacts;
DROP TABLE IF EXISTS config;
DROP TABLE IF EXISTS drafts;
DROP TABLE IF EXISTS email_addr_groups;
DROP TABLE IF EXISTS user_groups;
DROP TABLE IF EXISTS email_addr;
DROP TABLE IF EXISTS users;
-- CREATE TABLE IF NOT EXISTS contacts(
-- eid INT AUTO_INCREMENT PRIMARY KEY,
-- first_name varchar(50),
-- last_name varchar(50),
-- addr varchar(100)
-- );
CREATE TABLE IF NOT EXISTS users(
uid INT AUTO_INCREMENT PRIMARY KEY,
username varchar(50),
password varchar(100),
admin varchar(1)
);
CREATE TABLE IF NOT EXISTS email_addr(
eaid INT AUTO_INCREMENT PRIMARY KEY,
uid INT,
email_address varchar(100),
title varchar(100),
FOREIGN KEY (uid)
REFERENCES users(uid)
ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS user_groups(
gid INT AUTO_INCREMENT PRIMARY KEY,
uid INT,
group_name varchar(100),
group_desc TEXT,
group_color varchar(10),
FOREIGN KEY(uid)
REFERENCES users(uid)
);
CREATE TABLE IF NOT EXISTS email_addr_groups(
eaid INT,
gid INT,
FOREIGN KEY (eaid)
REFERENCES email_addr(eaid),
FOREIGN KEY (gid)
REFERENCES user_groups(gid)
);
CREATE TABLE IF NOT EXISTS config(
cid int AUTO_INCREMENT PRIMARY KEY,
uid int,
smpt_addr varchar(100),
email_username varchar(100),
email_password varchar(100),
FOREIGN KEY (uid)
REFERENCES users(uid)
);
CREATE TABLE IF NOT EXISTS drafts(
did int AUTO_INCREMENT PRIMARY KEY,
uid int,
sendType varchar(50),
sendto varchar(50),
subject varchar(50),
message TEXT,
FOREIGN KEY(uid)
REFERENCES users(uid)
);
INSERT INTO users (username, password, admin) VALUES('setest', 'c1333a0f215ff8f8dd7bbdc636ab4762', 'N');
INSERT INTO users (username, password, admin) VALUES('setest2', '7e54e03f709208b6fd164a3cf3f09202', 'N');
INSERT INTO users (username, password, admin) VALUES('seadmin', '9d9c79e0aa5e620c10ef24f67563af46', 'Y');
INSERT INTO email_addr(uid, email_address, title) VALUES(1, '[email protected]', 'FOR TESTING');
INSERT INTO email_addr(uid, email_address, title) VALUES(1, '[email protected]', 'FOR TESTING2');
INSERT INTO email_addr(uid, email_address, title) VALUES(2, '[email protected]', 'FOR TESTING');
INSERT INTO email_addr(uid, email_address, title) VALUES(2, '[email protected]', 'FOR TESTING');
INSERT INTO email_addr(uid, email_address, title) VALUES(2, '[email protected]', 'FOR TESTING');
INSERT INTO email_addr(uid, email_address, title) VALUES(1, '[email protected]', 'FOR TESTING');
INSERT INTO email_addr(uid, email_address, title) VALUES(1, '[email protected]', 'FOR TESTING2');
INSERT INTO email_addr(uid, email_address, title) VALUES(1, '[email protected]', 'FOR TESTING3');
INSERT INTO user_groups(uid, group_name, group_color) VALUES(1, 'TEST', 'success');
INSERT INTO user_groups(uid, group_name, group_color) VALUES(1, 'ANOTHER GROUP', 'success');
INSERT INTO email_addr_groups(eaid, gid) VALUES(1, 1);
INSERT INTO email_addr_groups(eaid, gid) VALUES(2, 1);
INSERT INTO email_addr_groups(eaid, gid) VALUES(3, 1);
INSERT INTO email_addr_groups(eaid, gid) VALUES(4, 2);
INSERT INTO email_addr_groups(eaid, gid) VALUES(5, 2);
INSERT INTO email_addr_groups(eaid, gid) VALUES(6, 2);
INSERT INTO config(uid, smpt_addr, email_username, email_password) VALUES(1, 'ssl://smtp.gmail.com', '[email protected]', 'seproject')
-- SELECT email_addr.email_address
-- FROM email_addr JOIN email_addr_groups
-- ON email_addr.eaid = email_addr_groups.eaid JOIN user_groups
-- ON email_addr_groups.gid = user_groups.gid
-- WHERE user_groups.gid = 1;
-- INSERT INTO contacts (first_name, last_name, addr)VALUES('t_f_name', 't_last_name', '[email protected]');