Reply
Can any DBAs help me with my Models?
Old 01-21-2008, 10:07 PM Can any DBAs help me with my Models?
Super Talker

Posts: 121
Name: Alan
Okay, here is what I want to do (not exactly but it's completely analogous):

There are Companies. Companies have some information, such as name and website and general info. They will have an ID and that will be the primary key.

There are Users. Users have info like email address, password, which company/ies they work for (eek... can a database store an "array" of companies worked for?!), and basic housekeeping stuff like preferences. They will have an ID and that will be the primary key, unless maybe email address works better, since that is guaranteed to be unique.

What I want to do is have users vote on their companies. Do they like working for their company? Other users can also vote on other companies like what they think about them.

I was thinking of having a Votes model, where each row would contain the user who voted and the company voted for and the score that was given, but I think that this would scale very poorly.

What is the proper way to set something like this up? (By the way, is this a basic problem? intermediate?) Do the models change if I want to, rather than figure average rankings out on demand, store the average ranking so that it gets updated less frequently to reduce overhead?

Thanks so much!
aschwa is offline
Reply With Quote
View Public Profile Visit aschwa's homepage!
 
When You Register, These Ads Go Away!
     
Old 01-21-2008, 11:03 PM Re: Can any DBAs help me with my Models?
ForrestCroce's Avatar
Half Man, Half Amazing

Latest Blog Post:
Talapus Lake in June Snow
Posts: 3,014
Name: Forrest Croce
Location: Seattle, WA
You could have a users table, a companies table, and an employment history table, so that one person can have worked for several companies.

Calculating the average ahead of time vs on demand depends on how people use your application ... but the overhead of updating averages every time someone votes is probably going to take a lot of avg queries to be worthwhile.
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 01-21-2008, 11:06 PM Re: Can any DBAs help me with my Models?
Super Talker

Posts: 121
Name: Alan
Quote:
Originally Posted by ForrestCroce View Post
You could have a users table, a companies table, and an employment history table, so that one person can have worked for several companies.

Calculating the average ahead of time vs on demand depends on how people use your application ... but the overhead of updating averages every time someone votes is probably going to take a lot of avg queries to be worthwhile.
Thank you.

Do you know how I might efficiently implement the actual table data for the votes?
aschwa is offline
Reply With Quote
View Public Profile Visit aschwa's homepage!
 
Reply     « Reply to Can any DBAs help me with my Models?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12618 seconds with 13 queries