Grant Holmes Posted February 25, 2008 Share Posted February 25, 2008 Hey gang. A little discussion here. I need to create a membership area. I found a script here from http://phpsnips.com/snippet.php?id=16 That would allow creation of a basic user. We're going to collect other basic demographic information, including a couple photos. I assume I should only use one database. Should I have this initial user file setup information (above) ONLY in one table and all the other information (call this demographic stuff) in another table? Should the photo images (ONLY) be in a totally separate table, or should the images be in with the demographic stuff? I know little about PHP and nothing about "Joining" tables, but I'm learning. Please give me guidance on how best to proceed. Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 25, 2008 Share Posted February 25, 2008 Personally, I would have photos being in their own table, each photo having its own row and having reference back to a unique id for whatever user that photo belongs to. From there you can pull all the photos from the table depending on what id you're referring to. Make sense? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted February 25, 2008 Share Posted February 25, 2008 the question of if I need a new table for some data comes down to answering the question "Can I have all this data stored in rows that are linked by a single key" If the answer is no make tables to satisify it If its yes you are good In your case the answer is no because the photos need to be many photos to 1 row, and mysql doesn't expand that way naturally (adding additional fields) Quote Link to comment Share on other sites More sharing options...
mem0ri Posted February 25, 2008 Share Posted February 25, 2008 You'll actually want to look into "relational database tables". There are several good articles on the web about them. As a previous reply mentioned, the a great way to think about it is "does all this information fit easily on one row". You might also want to ask yourself "is this information likely to be duplicated over and over again within my rows". If so...and dependent on the complexity of the information...you'll also want to build a separate table for that information. If you take some time to build your database tables correctly, you will save a myriad of headaches down the road. Quote Link to comment Share on other sites More sharing options...
revraz Posted February 25, 2008 Share Posted February 25, 2008 There are good articles posted in the MySQL forum. Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted February 25, 2008 Author Share Posted February 25, 2008 Thanks all for the great informative replies. In this case, we'd be limiting users to five image, not unlimited. And for the most part, I FEEL like it could be in one row, one for each user. Is there "more security" in having 'user' information separate from 'demographic' information? I would think this would be moot, but am unsure. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted February 25, 2008 Share Posted February 25, 2008 separating it makes more sense cause you always have the "what if I want 6 or 7" However for something like that 5 would be the max, such as alternative email addresses, anything over 5 should be a subtable of users Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.