Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 8th, 2007, 12:23 AM   #1
Writlaus
Hobbyist Programmer
 
Writlaus's Avatar
 
Join Date: Nov 2005
Posts: 149
Rep Power: 3 Writlaus is on a distinguished road
mysql efficiency

I have been dealing with mysql for a while now, but I still don't really know how exactly it works, or the most efficient way to do certain things. Is there some web page that explains how it works on a basic level?

One example is that I have one table for the users' accounts, with an id number, username, and password, and then I have other tables called "user_1","user_2", etc. that are created dynamically with the user's id number, when the account is created. These other tables hold more information about that user that seem to be more easily organized in their own tables. Does this impact the efficiency of the system? Will mysql be "bogged down" if it has too many tables?
Writlaus is offline   Reply With Quote
Old Jul 8th, 2007, 1:33 AM   #2
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 778
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Database Normalization
titaniumdecoy is offline   Reply With Quote
Old Jul 8th, 2007, 2:34 AM   #3
Jimbo
Expert Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 706
Rep Power: 3 Jimbo is on a distinguished road
Yes, there is a level at which performance is affected by the number of tables; how much it's affected, I don't know. Your design is very inefficient though. You'd need a table to keep track of what tables you have; why not just keep the data all inside one table (or a small number of tables)?
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote
Old Jul 8th, 2007, 3:55 AM   #4
Writlaus
Hobbyist Programmer
 
Writlaus's Avatar
 
Join Date: Nov 2005
Posts: 149
Rep Power: 3 Writlaus is on a distinguished road
I forgot to mention that this was done on another project of mine a while ago, and now I have come to the same dilemma. This time I decided to ask if it was a smart thing to do.

Jimbo, the project I did that with was a poll website where it kept track of what specific users voted, so you could see things like how many people voted yes to poll A and poll B. I had the "user_n" tables basically just keep a record of all of their answers. I then had each poll record on the poll table keep a simple tally on the votes, as well as the ID of each user that voted.

And I've actually come up with a better way to do the project I'm currently working on, but I still can't think of a better way I could have done the poll thing. For curiosity's sake, can anyone think of a better way to do that?
Writlaus is offline   Reply With Quote
Old Jul 8th, 2007, 4:22 AM   #5
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 778
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
As I meant to suggest via the link in my last post, you can use database normalization techniques to brainstorm the most robust design for your database. I suggest you do some research on the subject.

As for your poll example, my solution would be: Create a users table (userid, username, etc.). Create a new table users_to_polls to associate each user with each poll they vote in (u2pid, userid, pollid, response). Create a new table for each poll (pollid, question, etc.).

Last edited by titaniumdecoy; Jul 8th, 2007 at 4:35 AM.
titaniumdecoy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting MySQL and PHP titaniumdecoy PHP 10 Feb 25th, 2008 7:47 PM
MySQl simple problem paulchwd Other Web Development Languages 7 Feb 27th, 2007 10:31 AM
MySql paulchwd Other Web Development Languages 8 Feb 8th, 2007 9:17 PM
Tutorial - Using MySQL in C# Darkhack C# 12 Jan 17th, 2006 9:28 AM
Simple Perl / MySQL Problem.. pls help! domquemo Perl 0 Jan 11th, 2006 4:08 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:05 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC