Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Voting System

Author  Topic 

jesus4u
Posting Yak Master

204 Posts

Posted - 2003-08-21 : 13:20:57
Please I need some advice...
I need to build a voting mechanism into the content being displayed onto our website. So when users submit content, there are 4 people that need to vote on it for it to be approved; excluding the content provider.

So I thought it might be easy to use just 3 tables.

1.Users
2.Content
3.UsersContent

In the UsersContent Table there would be a Vote column (int). So their individual votes would be 1 (ok), 0 (no). The other columns would be what you expect. ID(int auto), UID(int FK to Users), ItemID(int FK to Content).

What do you suggest I do, if different?

Thanks

Alex Polajenko

nr
SQLTeam MVY

12543 Posts

Posted - 2003-08-21 : 14:21:39
Doesn't need the ID as UID, ItemID would be the PK.
You could be a bit more flexible - give a 0 to 10 vote and something like the sum of votes above 5 must be greater than 50.
Depends what the requirement really is.
If you are expecting a lot of data in the table then could use a tinyint for the vote.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jesus4u
Posting Yak Master

204 Posts

Posted - 2003-08-21 : 15:47:43
Thanks for the ideas nr!

What would you suggest as to where the logic for determining outcome should lie? In the SP or some Class in the project code; Like .NET Class?

THanks

Alex Polajenko
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-08-21 : 18:35:42
Up to you really.
The SP could return a value which the app then decides if it is a pass or fail or the SP could return a pas/fail.
Depends a bit on yoiur implementation.
I would probably have a table for the vote parameters - one of these would be the threshold and the SP would join to that with the sum - if greater than threshold then it returns pass.
In that way you could configure the vote via that table. If you wanted to chenge the value or method of computiong for a single vote then you could do it without affecting the app.

Would you want the app to know how close the vote is to passing? Then you would need to return more data and might want to do more in the app - or the SP could return a percentage where 100% = pass.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jesus4u
Posting Yak Master

204 Posts

Posted - 2003-08-22 : 07:47:57
Those are great suggestions! What I was thinking was to simply query the Voting table for all the users that have been assigned to the specific content then see if the total positive votes are = to the number of users. If so then it passes. PRetty simple but that is all I really need it to do.

Anymore suggestions?

Thanks again...

Alex Polajenko
Go to Top of Page
   

- Advertisement -