[thelist] SQL query help

rudy r937 at interlog.com
Wed Jan 2 11:48:28 CST 2002

> Because of the one vote per hour thing, I wanted the poll_id
> in the poll_answers table so the SQL would be simpler and
> quicker for looking for the IP.

hi erik

<tip type="data modelling">
never let the avoidance of sql complexity drive your table design

i was biting my tongue trying not to comment on your poll design, as i,
too, could see several ways to improve it

the sql i gave you was horribly complex (did it work, by the way?  it would
be nice to know, in case i was wrong, because i like to put out little
fires like that before they turn into big ones)

but like my tip says, sql complexity avoidance is not the main design

matt gave you many good things to think about, and don't let the fact that
you're already making multiple calls to the database worry you needlessly
(there's not much you can do about it short of writing an even more complex
stored procedure)

anyhow, i just thought i'd add one point --

if you are looking to restrict duplicates (e.g. the same IP number)
consider using a unique constraint, and let the database do it for you

it would have to be a multi-column constraint (e.g. including poll number),
so make sure your database can handle that (sql/server can)


More information about the thelist mailing list