MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old April 25th, 2000, 08:02 AM
cpy cpy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 4 cpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i am developing a web site using php+mysql to allow users to register/signup...

i am considering 2 options...

1) store userid + password + email + personal particulars such as address, contact info ...(about 20 fields) all in one table

2) use one table to store [userid + password + email] and another to store [userid + all personal particulars]

the only queries would be insert/update/select

option 1), though more straight forward, may result in more "congestion" as the table is likely to be used very often...
while option 2) may result in inconsistent records as mysql does not support transactions and rollbacks

any clever way of implementing option 1) without incurring high overhead? or is my concern unfounded?

thanks

Reply With Quote
  #2  
Old April 25th, 2000, 09:32 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
Option 1 shouldn't be too big of a concern if you only pull the fields you need when querying.

Option 2 shouldn't be a concern as you can use the last insert id option to get the userid (assuming you are using an auto_increment field to generate it) for the second table update. IOW, the userid should be auto_incremented in only 1 table.

The logical flow would be:

1) insert into first table
2) get last insert id
3) insert into second table setting userid to the userid received with last_insert_id


Reply With Quote
  #3  
Old April 25th, 2000, 08:50 PM
cpy cpy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 4 cpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
> 1) insert into first table
> 2) get last insert id
> 3) insert into second table setting userid to the userid received with last_insert_id

my concern is that if 1) is successful but 3) is not - maybe user hit STOP button after 1) but before 3), or database insertion error, then i'll be in trouble...right?

Reply With Quote
  #4  
Old April 26th, 2000, 07:03 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
You'd only be in trouble insofar as that one insert. The next user would still be correct. You can set up a cron job to compare the two tables periodically, or have the second table be the one with just the login id. Set ALL info including the login info into the first table. If someone signs in and isn't in the second table you could verify against the first to double check. If they are there, update the 2nd table then.

BTW, the user hitting the stop button is not going to affect the PHP script in most circumstances, especially if you are not outputting to the browser between the two queries, the script will continue to run.
There is also a setting I can't recall now, check the manual, that tells PHP to execute the script to completion no matter what the user does.

As far as errors, thorough testing should catch all possible bugs in your code that might cause a problem with the second insert.

Still, a once an hour cron job should catch any problems and be more than sufficient. If you really want to see if you had a concern or not, you can have the cron job log any repairs it performs.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > new table design advice needed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway