Which is better? Tons of separate tables with a little data or one big table?

Reply

Join Date: Feb 2007
Posts: 5
Reputation: igeek is an unknown quantity at this point 
Solved Threads: 0
igeek's Avatar
igeek igeek is offline Offline
Newbie Poster

Which is better? Tons of separate tables with a little data or one big table?

 
0
  #1
Nov 24th, 2008
I'm working on a web app in which each user will have their own account. Each account would have its own data (duh) and this data needs to be kept separate from everyone else (either by putting it in another database JUST for that user or combining all data into 1 database and then marking it with a "userid" that can be used to filter out every one else stuff.

Which would be better: having a different database for every user (created on signup via sql and php) that is named after their userid? Or is it better to combine all of the info into one massive database and just earmark things with an indexed "userid"?

Thanks

Performance might be an issue in the future so which is better for that?
Last edited by igeek; Nov 24th, 2008 at 8:03 pm.
I <3 Apple.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Which is better? Tons of separate tables with a little data or one big table?

 
0
  #2
Nov 24th, 2008
i don't think speed is necessarily going to be an issue, just be sure to make fk and primary keys, and indexes where necessary and you should be good using a single db

on top of that, it would be a nightmare for multiple databases, multiple upgrade scripts, i would most likely advise against it unless its truly a distributed application
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 5
Reputation: igeek is an unknown quantity at this point 
Solved Threads: 0
igeek's Avatar
igeek igeek is offline Offline
Newbie Poster

Re: Which is better? Tons of separate tables with a little data or one big table?

 
0
  #3
Nov 24th, 2008
Thanks for the reply. Yeah, I had considered that upgrading the app later might be a nightmare trying to process 1,000 different databases rather than changing just 1 big one (or at least it would be somewhat resource-intensive)

If I did a bunch of different databases (one for each account) then each database would also have a unique mysql user/pass. I was thinking it might be more secure so that each account can only access THEIR data in THEIR database rather than all data (using permissions). If someone could somehow find a way to hack in and get the universal msyql username/pass then I'm screwed b/c everything is in 1 place.

But using unique dbs and user accts, in order to hack into all data a person would have to get ALL the usernames/passwords which would be near-impossible.

Again, I really appreciate feedback
I <3 Apple.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Which is better? Tons of separate tables with a little data or one big table?

 
0
  #4
Nov 24th, 2008
you can specify sql user accounts and ip addresses if need be
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,040
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Which is better? Tons of separate tables with a little data or one big table?

 
1
  #5
Nov 25th, 2008
Someone once posted the analogy that a different database for every record is like a different hard drive for every file.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC