Table Setup for Polls

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Table Setup for Polls

Post by JAB Creations »

I decided to take a crack at creating a poll script and here is what I'm currently thinking about for setting up tables for the feature. Thoughts please?

Table: poll
id
date_0 - If !null when the poll start(s/ed)
date_1 - If !null when the pill end(s/ed)
public - 0 for private, 1 for public
question

Table: poll_choices
id
id_poll

Table: poll_votes
id
id_poll
id_user - If !null the id of the user
ip - The IP address of the voter.
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: Table Setup for Polls

Post by novice4eva »

Table: poll_choices
id
id_poll
choices
Last edited by novice4eva on Wed Dec 24, 2008 2:43 am, edited 2 times in total.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Table Setup for Polls

Post by JAB Creations »

choice, non-plural but yeah I would have noticed that once I began implementing this. Thanks for pointing that out!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Table Setup for Polls

Post by Chris Corbyn »

Don't you need id_choice in the votes table too?

EDIT | Also, don't call your columns date0 and date1. That's ludicrous! ;) date_start and date_end perhaps?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Table Setup for Polls

Post by JAB Creations »

Chris Corbyn wrote:Don't you need id_choice in the votes table too?
I'll JOIN poll_choices/id_poll with poll/id and it should work out in to a nice array. :)

Heh you should see my user_accounts table...

ip_0, ip_1, ip_2, date_0, date_1, date_2...etc. I usually use 0 for registration point or for options either "no preference" or "off" (in on/off only options).

It wouldn't be as much fun if you guys understood everything I was talking about. :twisted:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Table Setup for Polls

Post by Chris Corbyn »

I can understand using 0's and 1's as values, but using numbers in column headings sounds like bad voodoo (is there such a thing as good voodoo in software?) to me ;)

Descriptive names have always been better for everyone, including the guy writing the code! :D

EDIT | It's Christmas in 2 hours and I'm at home alone, on the interwebs, how sad is that? :( Good job I'm out for a BBQ tomorrow afternoon!
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Table Setup for Polls

Post by JAB Creations »

Lately I've been wondering if it was the UK or out in the Pacific that was where the day "starts"...I imagine you guys are ahead of us from what you posted. I take it you celebrate? I don't but will still spend time with family and friends nonetheless. Thanks for taking time out on your xmas eve to participate on the forums and have a happy holiday. :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Table Setup for Polls

Post by Chris Corbyn »

Well, GMT is at Greenwich, which is in the UK. I'm in Australian Eastern Standard TIME (EST) which is GMT + 10 and it's currently daylight saving so we're ahead by 1 hour making us GMT + 11 at the moment. We're the first "major" country to see the day start, but the first place on the globe as a little island called Kiribati out in the pacific, the places like Fiji and Tonga.

I do celebrate yeah, I'm actually from the UK, I'm just living out here. This has been the quietest xmas on record for me - I've never been home alone before (my housemate is with family, my family are in the UK, and the friends I considered spending time with are doing things with their own families). I'll be out for a BBQ (Shrimps anyone? :P) later today though :)

I guess I should go and open my 2 lonely-looking presents!
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Table Setup for Polls

Post by JAB Creations »

What goodies did you get?

A friend bought me a copy of STALKER: Shadow of Chernobyl on Steam though I probably won't play it until I upgrade my system from socket 939 to AM3 (in February) even though my current system could probably handle it. For the time being I'm working on this poll feature which is starting to pull me in to thinking I need to work on a control panel soon.

I am curious about where the day "starts" because I like Japanese anime. I usually don't watch shows that are still being produced but the 200th episode of Bleach came out on the 23rd, so it's good to feel that the day starts almost a day early there so it reduces the wait for subs. :mrgreen:

Why did you move all the way to Australia?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Table Setup for Polls

Post by Chris Corbyn »

I'm not much of a gamer so not sure what STALKER is but enjoy :)

I got $100 Prepaid Visa card from my employer and just a few little things (beer, a "Long words" calendar, chocs) left from my housemate. I'll get more pressies when I go over to my friends later today (I imagine, though I'm not fussed) since that's where everyone is meeting :)

I moved out here last September partly on impulse. I'm not particularly attached to the UK (it's a great place, but when summer last 1 week some years it can be depressing) and I'd always wanted to go backpacking in Australia. I met some aussies when I lived in Manchester (in the UK) and made friends with them for a year while they were in the UK... it just made it a lot less of a barrier to move out here. Booked a flight, spent a fortune organising my travel plans around Oz, then got offered a job with SitePoint and my travel plans went out of the window but it's all worked out great... I'm just taking short breaks in my annual leave to travel when I get time.
Post Reply