-
Notifications
You must be signed in to change notification settings - Fork 0
/
electronicVotingSystem.sql
164 lines (114 loc) · 3.48 KB
/
electronicVotingSystem.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
drop database voterDB;
create database voterDB;
use voterDB;
create table evs_tbl_user_credentials(
userid varchar(6),
password varchar(20) not null,
usertype varchar(1) check(usertype='A' or usertype='E' or usertype='V'),
loginstatus int(1) check(loginstatus=1 or loginstatus=0),
primary key(userid));
create table evs_tabl_user_profile(
userid varchar(6),
firstname varchar(15) not null,
lastname varchar(15) not null,
dateofbirth date,
gender varchar(7) not null,
street varchar(30) not null,
location varchar(15) not null,
city varchar(15) not null,
state varchar(15) not null,
pincode varchar(10) not null,
mobileno varchar(10),
emailid varchar(30),
foreign key(userid) references evs_tbl_user_credentials(userid));
create table evs_tbl_election(
electionid varchar(6),
name varchar(15) not null,
electiondate date,
district varchar(15) not null,
constituency varchar(15) not null,
countingdate date not null,
primary key(electionid));
create table evs_tbl_party(
partyid varchar(6),
partyname varchar(20),
leadername varchar(20),
symbol varchar(20),
primary key(partyid));
create table evs_tbl_candidate(
candidateid varchar(6),
name varchar(20) not null,
electionid varchar(6),
partyid varchar(6),
district varchar(20) not null,
constituency varchar(20) not null,
dateofbirth date not null,mobileno varchar(10),
address varchar(50) not null,
emailid varchar(20),
primary key(candidateid),
foreign key(electionid) references evs_tbl_election(electionid),
foreign key(partyid) references evs_tbl_party(partyid));
create table evs_tbl_application(
userid varchar(6),
constituency varchar(30) not null,
passedstatus int(2),
approvedstatus int(2),
voterid varchar(8),
primary key(voterid),
foreign key(userid) references evs_tbl_user_credentials(userid));
insert into evs_tbl_application values('sr1001','JAMANAGAR',1,1,1021);
create table evs_tbl_result(serialno int(6),
electionid varchar(6),
candidateid varchar(6),
votecount int(5),
primary key(serialno),
foreign key(electionid) references evs_tbl_election(electionid),
foreign key(candidateid) references evs_tbl_candidate(candidateid));
create table evs_tbl_eo(
electoralofficerid varchar(6),
constituency varchar(25) not null,
primary key(electoralofficerid));
create table evs_tbl_voter_details(
serialno int(6)primary key,
candidateid varchar(6),
electionid varchar(6),
voterid varchar(8),
foreign key(electionid) references evs_tbl_election(electionid),
foreign key(candidateid) references evs_tbl_candidate(candidateid),
foreign key(voterid) references evs_tbl_application(voterid));
/*
Drop trigger trg_cred_profile;
Delimiter //
create trigger trg_cred_profile
before insert on evs_tabl_user_profile
for each row
begin
set New.userid=CONCAT((substr(New.firstname,1,2)),New.userid);
update evs_tbl_user_credentials set userid=new.userid;
end //
delimiter ;
*/
/*
insert into two tables:
================================
*/
insert into evs_tbl_user_credentials values(
1001,'pwd1','A',0);
insert into evs_tabl_user_profile values(1001,'sridevi',
'atheli',current_date(),'Male','hyd','panjajutta','hyd','ts','500042',8123232323,
*/
/*
Delimiter //
create trigger trg_tbl_application
before insert on evs_tbl_application
for each row
begin
set New.voterid=concat(substr(New.userid,1,2),substr(New.constituency,1,2),New.voterid);
end //
delimiter ;
*/
select * from evs_tbl_user_credentials;
select * from evs_tabl_user_profile;
insert into evs_tbl_application values('sr1001','JAMANAGAR',1,1,1021);
select * from evs_tbl_application;