# Creating a Voting system

**URL:** <https://forum.adalo.com/t/creating-a-voting-system/4905>\
**Category:** Get Help\
**Created:** [October 14, 2020, 4:09pm UTC](https://forum.adalo.com/t/creating-a-voting-system/4905 "2020-10-14T16:09:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![robrea](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@robrea](https://forum.adalo.com/u/robrea)\
**Post date:** [October 14, 2020, 4:09pm UTC](https://forum.adalo.com/t/creating-a-voting-system/4905/1 "2020-10-14T16:09:05Z")

</div>

Hey helpful people! Hopefully this question makes sense!  
I am creating a stories app, where other users vote on the stories (a thumbs up or thumbs down vote). I want to know how to:

1. count the votes
2. Where should the votes be recorded in the database (ie a component within the stories or a new collection?)
3. how do i display the thumbs up votes as a percentage of all votes on the story page?

sorry if that didn’t make sense?

---

<div class="post-metadata">

**Author:** ![Victor](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/victor/32/2054_2.png) [@Victor](https://forum.adalo.com/u/Victor)\
**Post date:** [October 14, 2020, 5:20pm UTC](https://forum.adalo.com/t/creating-a-voting-system/4905/2 "2020-10-14T17:20:44Z")

</div>

Hi @robrea,

I would recommend to have a look at this tutorial: [How to create a "Favorite" button - Adalo Resources](https://help.adalo.com/how-to/how-to-create-a-favorite-button)  
Also, this one could be useful: [How to Allow Users to Follow Others - Adalo Resources](https://help.adalo.com/how-to/how-to-allow-users-to-follow-others)  
Replace “favorites” or “follow” with “Thumbs Up” and you may start from there 🙂  
If you use these as a basis, then you can allow users to “remove” their votes at any time.

Where to store the votes - that depends on what you want. If you don’t want to limit users from voting multiple times, you could just add 2 properties (upvote and downvote) for the story and then increase them.  
Or you could create a separate “votes” database table, and store “relation to user” - “relation to story” - “upvoted” - “downvoted” records for each user-story vote. And then calculate the number based on Count.

---

<div class="post-metadata">

**Author:** ![robrea](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@robrea](https://forum.adalo.com/u/robrea)\
**Post date:** [October 15, 2020, 7:40pm UTC](https://forum.adalo.com/t/creating-a-voting-system/4905/3 "2020-10-15T19:40:21Z")

</div>

Hi Victor,

Thanks so much for these resources. I have read through both, but still confused unfortunately (sorry!!). So:

Favourite Button tutorial:

1. My users essentially have 2 relationships to stories (a. 1 user can create many stories, b. many users can vote on many stories) - does this mean I have to create a different relationship for each type? ie 2 relationships in this case, one being 1:many and another many:many?
2. There is functions for toggle but essentially I have a like and dislike button so I want each to be able to toggle on and off but also to restrict a user to a single option (either like or dislike) and also to a single vote (you can change your mind but its still only counted as one vote)
3. Or do I set up 3 relationships a. 1 user can create many stories b. many users can like many stories c. many users can dislike many stories?

Follow Tutorial:

1. This was really great to know (although a little confusing!) so as soon as I understand the answers to the above questions I will implement the ‘follow’ but change it for the votes

You: Where to store the votes - that depends on what you want. If you don’t want to limit users from voting multiple times, you could just add 2 properties (upvote and downvote) for the story and then increase them  
Me: I definitely want to limit users to not only voting once but also only allowing them to like or dislike, not both. So you are saying to either add votes as a property of stories or to create a new votes collection?

Also, is there a way to display percentage? ie what percentage of voters liked the story rather than just count?

Thanks so much for your help Victor!!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/system/32/40401_2.png) [@system](https://forum.adalo.com/u/system)\
**Post date:** [October 25, 2020, 7:40pm UTC](https://forum.adalo.com/t/creating-a-voting-system/4905/4 "2020-10-25T19:40:22Z")

</div>

Closed on October 25, 2020, 7:40pm UTC

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
