-
Notifications
You must be signed in to change notification settings - Fork 1
/
cv_schema_init.py
172 lines (157 loc) · 3.31 KB
/
cv_schema_init.py
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
CREATE_SCHEMA = """
CREATE SCHEMA IF NOT EXISTS `mydb`;
"""
Create_users_Table = """
CREATE TABLE IF NOT EXISTS mydb.Users(
name VARCHAR(45) NOT NULL,
email Varchar(120) Not NULL,
type VARCHAR(45) NOT NULL,
password VARCHAR(45) NULL,
UNIQUE INDEX email_UNIQUE (email),
CHECK (type in ('Recruiter','Client','Administration')),
PRIMARY KEY (email) );
"""
Create_recruiter_Table = """
CREATE TABLE IF NOT EXISTS mydb.Recruiter(
RID INT NOT NULL AUTO_INCREMENT,
RName VARCHAR(45) NOT NULL,
REmail VARCHAR(45) NOT NULL,
CompanyName VARCHAR(45) NOT NULL,
CompanyLocation VARCHAR(45) NOT NULL,
RGender VARCHAR(2) NOT NULL,
PRIMARY KEY (RID),
UNIQUE (REmail)
);
"""
Create_client_Table = """
CREATE TABLE IF NOT EXISTS mydb.Client (
CID INT NOT NULL AUTO_INCREMENT,
CName VARCHAR(45) NOT NULL,
CEmail VARCHAR(45) NOT NULL,
CAge INT NOT NULL,
CLocation VARCHAR(45) NOT NULL,
CGender VARCHAR(2) NOT NULL,
CExp INT NOT NULL,
CSkills VARCHAR(45) NOT NULL,
CQualification VARCHAR(45) NOT NULL,
UNIQUE (CEmail),
PRIMARY KEY (CID)
);
"""
Create_Job_Table = """
CREATE TABLE IF NOT EXISTS mydb.Job (
RID INT NOT NULL,
JID INT NOT NULL AUTO_INCREMENT,
JobRole VARCHAR(45) NOT NULL,
JobType VARCHAR(45) NOT NULL,
Qualification VARCHAR(45) NOT NULL,
MinExp INT NOT NULL,
Salary INT NOT NULL,
FOREIGN KEY (RID) REFERENCES mydb.Recruiter(RID),
PRIMARY KEY (JID)
);
"""
Create_Application_Table="""
CREATE TABLE IF NOT EXISTS mydb.Application(
AID INT NOT NULL AUTO_INCREMENT,
RID INT NOT NULL,
JID INT NOT NULL,
CID INT NOT NULL,
PRIMARY KEY(AID),
FOREIGN KEY(RID) REFERENCES mydb.Recruiter(RID),
FOREIGN KEY(JID) REFERENCES mydb.Job(JID),
FOREIGN KEY(CID) REFERENCES mydb.Client(CID)
);
"""
Create_DELJOB_Table="""
CREATE TABLE IF NOT EXISTS mydb.DELJOB(
JID int,
RID int,
JObRole varchar(45),
Deleted_At datetime
);
"""
Create_DELAPP_Table="""
CREATE TABLE IF NOT EXISTS mydb.DELAPP(
CID int,
JID int,
Deleted_At datetime
);
"""
Create_NEWJOB_Table="""
CREATE TABLE IF NOT EXISTS mydb.NEWJOB(
JID int,
RID int,
JObRole varchar(45),
Created_At datetime
);
"""
Create_NEWAPP_Table="""
CREATE TABLE IF NOT EXISTS mydb.NEWAPP(
CID int,
JID int,
Created_At datetime
);
"""
CREATE_Admin="""
INSERT INTO users
VALUE("BhaveshPatil", "ADMIN", "Administration", "password")
"""
JobTrig1="""
CREATE TRIGGER jobTrig1
BEFORE DELETE ON Job FOR EACH ROW
BEGIN
INSERT INTO DelJob
SET JID=OLD.JID,
RID=OLD.RID,
JOBRole=OLD.JOBrole,
Deleted_AT=NOW();
END
"""
JobTrig2="""
CREATE TRIGGER jobTrig2
AFTER INSERT ON Job FOR EACH ROW
BEGIN
INSERT INTO NewJob
SET JID=NEW.JID,
RID=NEW.RID,
JOBRole=NEW.JOBrole,
Created_AT=NOW();
END
"""
AppTrig="""
CREATE TRIGGER appTrig
BEFORE DELETE ON application FOR EACH ROW
BEGIN
INSERT INTO DelAPP
SET CID=OLD.CID,
JID=OLD.JID,
Deleted_AT=NOW();
END
"""
totalAPP="""
CREATE PROCEDURE no_of_app()
BEGIN
SELECT COUNT(JID) AS No_Of_JobApplications
FROM application;
END
"""
totalJOB="""
CREATE PROCEDURE no_of_job()
BEGIN
SELECT COUNT(JID) AS No_Of_Jobs
FROM job;
END
"""
totalUSERS="""
CREATE PROCEDURE no_of_users()
BEGIN
SELECT COUNT(email) AS No_Of_Users
FROM users;
END
"""
Log_View="""
CREATE VIEW log AS
SELECT email,password
FROM users
"""