0

I need to build a website where users can upload their photos, and vote other people photo, like Facebook like

i was thinking the best ( or only way ) to store this info:

1 - i can just use a simple counter on photo records, and check in session if people would vote more than once ( vote are just for fun ) but on a new session i can vote the same photo again

2 - the other way is create a table where i store userid and photoid, this way user can't vote more than once, but i'm not sure if database grow could became an issue since table will grow larger and larger

3 - A text field on user record where i store a list of photo id, and i can build a session array on login or just build a PHP array on page load. This could be the best way, i guess i can have issue if i need to search or count on specific situations. LONGTEXT should contain 4Gb so i think i would never reach maximum lenght

al404IT
  • 1,380
  • 3
  • 21
  • 54

3 Answers3

1

I'm assuming your question is:"What is the best way?" I would say 2 would be the best since that's the easiest to check wether a person has voted yet. The table won't get too big. People are using tables also for registering users and those can be alot as well.

Loko
  • 6,539
  • 14
  • 50
  • 78
  • each user can vote unlimited photo, so if i get 100.000 users and each would vote 1000 photo i would get 100.000.000 – al404IT Nov 13 '13 at 09:26
  • @al404IT Still think it's not too big. 2 Should be the best solution. – Loko Nov 13 '13 at 09:29
  • i found this answer also http://stackoverflow.com/questions/1276/how-big-can-a-mysql-database-get-before-performance-starts-to-degrade – al404IT Nov 13 '13 at 10:24
  • @al404IT That answer is good. Of course the answer is about how big a database can get. – Loko Nov 13 '13 at 10:46
0

yes you can move forward with the idea of text field on user record to store comma or pipe separated photo id

or text field on the photo record to store comma or pipe separated user id who liked that photo.

Its much better than creating a relational table

Veerendra
  • 2,562
  • 2
  • 22
  • 39
0

Here what you are trying to do is trying to create a website like Mark Zuck created earlier (Facemash). http://www.facemash.com.au/

You can download this script from http://webtify.com/internet/facemash-clone-script/802/

Regarding your logic : I think that #3 is good for this script

5eeker
  • 1,016
  • 1
  • 9
  • 30