I'm developing an android voting application. I have this code that inserts voters emails into a candidates key to help me count the total votes.
public static void insertvote(String userkey, String categ, String candId, String uid) {
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference totalVotesRef = rootRef.child("votes").child(categ).child(candId);
Vote vote = new Vote(userkey);
totalVotesRef.child(uid).setValue(vote.getVoterEmail());
It generates below results in firebase:
How can I enforce an email to only vote once and if it exists in the specific category, it disallows voting again? (For example in the image above, hr@gmail.com has been listed twice instead on only once meaning they can vote for a president twice) Thanks in advance.