You are on page 1of 27

Designing and implementing a Relational DBMS on

ONLINE VOTING SYSTEM


Submitted to the

Savitribai Phule Pune university

In partial fulfillment for the award of the degree of

Bachelor of Engineering

In

Electronic and telecommunication

By
Saurabh Sontakke- TE238

Viraj Ravenkar -TE256

Mathura Rajurkar-TE253

Under the guidance of

Mr. Nikhil Dhavase

Department of ENTC

Marathwada Mitra Mandels’s

College of Engineering

Karvenagar, Pune -411052

2021-2022
i
CERTIFICATE

This is to certify that the mini project report entitled “Online voting system” being submitted
by Saurabh Sontakke, Viraj ravenkar , Mathura rajurkar is a record of Bonafide work
carried out by her under the supervision and guidance of Mr. Nikhil Dhavase in partial
fulfillment of the requirement for TE Entc 2019 course of Savitribai Phule Pune University,
Pune in the academic year 2020-2021.

Date: 31th May 2021

Place: Pune

Nikhil Dhavase
Guide

This Mini Project report has been examined by us as per the Savitribai Phule Pune University,
Pune requirements at MMCOE, Pune on 18th feb 2020

Internal Examiner External Examiner

ii
ACKNOWLEDGEMENT

We have taken a lot of effort into this project. However, completing this project would not
have been possible without the support and guidance of a lot of individuals. We would like to
extend our sincere thanks to all of them.

We are highly indebted to Mr. Nikhil Dhavase for their guidance and supervision. We would
like to thank him for providing the necessary information and resources for this project. We
would like to express our gratitude towards our parents & our friends for their kind co-
operation and encouragement which help us a lot in completing this project.

Our thanks and appreciations also go to our classmates in developing the project. Thank you
to all the people who have willingly helped us out with their abilities.

Thanking you.

iii
ABSTRACT

In this project we created a application which is easy to access and user friendly. For this
application we used the backend as MySQL to store the data which is used in the application
and for the user interface, we can use PHP and HTML but here we have created a database
only.
In order for the representative to appropriately represent and implement the demands of the
people, the elections in which they are elected must be held fairly and results computed
accurately.

Achieving this objective is difficult using a manual system as the information is scattered,
can be redundant and collecting relevant information may be very time consuming. All these
problems are solved using this project.

iv
INDEX

Chapter Topic Page No.


No.
Abstract

1. Introduction 6

1.1 Problem statement 7

1.2 Motivation 7

1.3 Objective 7

2. Data type 8

3. Data Modelling using ER Model 9

3.1 Requirement, Collection & Analysis 9

3.1.1 Entity types & Sets, Attributes & Keys 10

3.2 ER Diagram 11

3.2.1 Relational DB Design using ER to relational mapping 12-13

4. Creating DB using MySQL 14-16

5. Test Queries 17-29

Conclusion 30

References 31

v
CHAPTER 1
INTRODUCTION

Online voting system is a voting technique. It protects the integrity of vote by preventing
voters from being able to vote multiple times. As a digital platform, they eliminate the need
to gather in-person, cast votes using paper, or by any other means (e.g., email, insecure
survey software).

In this system the voter do not have to go to the polling booth to cast their vote. They can use
their personal computer to cast their votes. There is a database which is maintained in which
all the name of the voters with their complete information is stored. The System
Administrator registers the voters by simply filling a registration form to register the voters.
After registration, the voter is assigned a secret voter ID with which he/she can use to login to
the system and cast his/her vote. If invalid/wrong details are submitted, then the person is not
registered to vote.

The advantage of online voting is that the voters have the choice of voting at their own free
time and there is reduced congestion. It also minimizes on errors of vote counting.

1.1 Problem Statement.

To develop a database using MySQL which contains the data of candidate like Name,
candidate Id, etc. This system is capable of displaying the results of a particular student.

1.2 Motivation

DBMS provides a fair advantage over file systems in case of data redundancy, inconsistency,
data sharing, data concurrency, data searching, data integrity and system crashing. Therefore,
DBMS was chosen to create the online voting system so that it can be easily accessible.

1.3 Objectives
To Develop a system that will manage:
1. Information about various candidates.
2. Information of various voters.
3. Information regarding the position

vi
CHAPTER 2
DATA TYPES

1. Integer: one optional sign character (+ or -) followed by at least one digit (0-9).
Leading and trailing blanks are ignored. No other character is allowed.
2. Varchar: it is used to store alpha numeric characters. In this data type we can set the
maximum number of characters upto 8000 ranges by the default SQL server will set
the size to 50 characters range.
3. Date: the DATE data type accepts date values. No parameters are required when
declaring a DATE data type. Date values should be supported in the form YYYY-
MM-DD. However, point base will also accept single digit entries for month and day
values.
4. Time: the TIME data type accepts time values. No parameters are required while
declaring a TIME data type.
5. Binary: it has a maximum length of 8000 bytes. It contains fixed length binary data.
6. Float: It is used to specify a floating-point value.
7. Real: it specifies a single precision floating point number.
8. Bit: It has the number of bits to store.
9. Decimal: It specifies a numeric value that can have a decimal number.
10. Numeric: it is used to specify a numeric value.

vii
CHAPTER 3
Data Modeling using ER Model

3.1 REQUIREMENTS COLLECTION AND ANALYSIS

We list the data requirements for the database project here, and then create its conceptual
schema step-by-step as we introduce the modeling concepts of the ER model. The online voting
system database keeps track of candidates information such as id, first name, last name,
position_id etc Suppose that after the requirements collection and analysis phase, the database
designers provide the following description of the mini world—the details of that candidate
will be represented in the database. The voting database is organized according to the attributes
of candidate

3.1.1 Entity Types, Entity Sets, Attributes, and Keys


•Candidate: Attributes of candidate are:
1. id
2. firstname
3. lastname
4. position_id
5. photo
6. platform

• Admin: Attributes of admin are:

1. Id
2. Username
3. password
4. Firstname
5. Lastname
6. Photo
7. Created_on
•Voters: Attributes of voter list are:
1. id
2. firstname
3. lastname
4. Password
5. Photo
6. Voters_id

viii
• Votes: Attributes of vote:

1. Id
2. Position_id
3. Candidate_id
4. Voter_id
• position: Attributes of position are:

1. Id
2. Voters_id
3. Candidate_id
4. Description

3.2 E-R Diagram

An entity–relationship model (ER model) describes inter-related things of interest in a


specific domain of knowledge. An ER model is composed of entity types (which classify the
things of interest) and specifies relationships that can exist between instances of those entity
types. In software engineering an ER model is commonly formed to represent things that a
business needs to remember in order to perform business processes. Consequently, the ER
model becomes an abstract data model that defines a data or information structure that can be
implemented in a database, typically a relational database
This ER (Entity- Relationship) diagram represents the Online Voting Management System
Entity. The ER diagram of Online Voting Management System shows all visual instruments
of database table and relationship between Citizen,Voting Center,Vote, Candidate etc.

ix
Fig-3.1 ER diagram for online voting

3.2.1 Relational Database Design Using ER-to-Relational Mapping

Fig 3.2 Relational database design

x
Step 1: Mapping of Regular Entity Types:

For mapping the the regular entity types, we need to create a relation which will link the entity
and its simple attributes. The relations HAS is created to correspond to the regular entity types
which are voters, votes and position The foreign key and relationship attributes, are not
included yet; they will be added during subsequent steps. We have chosen voters_id,
candidate_id ,position_id as primary keys for the tables voters, votes, position respectively.

Step 2: Mapping of Weak Entity Types:

There are no weak entities here as all the entities included in the database are strong entities
and can be identified uniquely.

Step 3: Mapping of binary 1:1 relationship types

In this database,we have identified two 1:1 relationship namely voters HAS voters_id and
position HAS position_id.

Foreign key approach:


In our project we map 1:1 relationship type ’HAS’ from Fig 3.1 by choosing the participating
entity as ‘candidate’ to serve in the role of the relationship because its participation in the
‘HAS’ relationship type. We include the primary key of the candidate relation as foreign key
in the votes relation and rename it as ID.

Step 4: Mapping of Binary 1:N Relationship Types.

In this database, we have identified one 1:N relationship namely candidate HAS position,
voters and votes, each of which having common ID.

xi
CHAPTER 4

CREATING DATABASE USING MYSQL

Table structure for table `admin`


CREATE TABLE `admin` (
`id` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`password` varchar(60) NOT NULL,
`firstname` varchar(50) NOT NULL,
`lastname` varchar(50) NOT NULL,
`photo` varchar(150) NOT NULL,
`created_on` date NOT NULL

);
INSERT INTO `admin` (`id`, `username`, `password`, `firstname`, `lastname`, `photo`,
`created_on`) VALUES
(1, 'Nandita', '123@', 'Nandita', 'Sharma', 'profile-image.jpeg', '28-05-2021');

CREATE TABLE `candidates` (


`id` int(11) NOT NULL AUTO_INCREMENT,
`position_id` int(11) NOT NULL,
`firstname` varchar(30) NOT NULL,
`lastname` varchar(30) NOT NULL,
`photo` varchar(150) NOT NULL,

xii
`platform` text NOT NULL
);

CREATE TABLE `positions` (


`id` int(11) NOT NULL AUTO_INCREMENT,
`description` varchar(50) NOT NULL,
`max_vote` int(11) NOT NULL,
`priority` int(11) NOT NULL
);

CREATE TABLE `voters` (


`id` int(11) NOT NULL AUTO_INCREMENT,
`voters_id` varchar(15) NOT NULL,
`password` varchar(60) NOT NULL,
`firstname` varchar(30) NOT NULL,

xiii
`lastname` varchar(30) NOT NULL,
`photo` varchar(150) NOT NULL
);

CREATE TABLE `votes` (


`id` int(11) NOT NULL,
`voters_id` int(11) NOT NULL,
`candidate_id` int(11) NOT NULL,
`position_id` int(11) NOT NULL
);

xiv
CHAPTER 5
TEST QUERIES
1. Display voter_id , firstname, lastname using inner join with tables voters and votes

2. Display last inserted id from table candidates

xv
3. Display distinct firstname from table candidates

4. Display all votes having position_id 4.

xvi
5. display firstname from table candidates in alphabetically order.

6. Display minimum vote from max_vote from table position.

xvii
7. Display max vote from max_vote from table position.

8. Display firstname from table candidates starting with letter A .

xviii
9. Display table candidates having platform online

10. display count from table positions.

11. display sum of max_vote from table positions.

xix
12. display table votes ordered based on voters_id.

13. display votes not having position_id =3.

xx
14. display table votes not having voters_id =2 and id = 4.

15. display table positons having max_vote between 100 and 123.

xxi
16. Display id and sum(max_vote) from table positions using appropriate clause.

17. Display table position provided that max_vote >100.

xxii
18. Display table candidates in descending order of position_id.

19. Display row from table votes having first digit as 4 in candidate_id column.

20. Display max_vote from table positions having last digit as 5

xxiii
21. Display firstname , lastname, candidate_id ,position_id from table voters using joins.

22. Display table candidates with limit 3.

23. Reverse firstname from table candidates.

xxiv
24. Convert firstname from table candidates into lowercase.

25. Display firstname , lastname, plateform from table candidates having null value.

26. Display firstname , lastname, plateform from table candidates having not null value.

xxv
CONCLUSION

A database for ONLINE VOTING SYSTEM was created using MySQL. Some information
was added in the database with the appropriate entities and attributes. Various operations
were performed on the database. 25 different queries were tested. All the 25 queries have
successfully displayed output as per the snapshots uploaded above this section. Hence Online
voting system was successfully created and tested using MySQL. This system can be used to
organize data in a systematic way and interpret data as per the user’s needs.

xxvi
REFERENCES

[1] Web Documentation [Online] Available from


https://db.grussell.org/section006.html
2021/05/27 [Accessed on 27th May 2021]

[2] Creatly. ER Creator [Online] Available from https://app.creately.com /2021/05/27


[Accessed on 27th May 2021].

[3] Javatpoint. MySQL. Web Documentation. [Online]/ Common mysql queries_/


Available From https://www.javatpoint.com/sql-select-from-multiple-tables
/2021/05/28 [Accessed on 28th May 2021]

xxvii

You might also like