So, the database would be structured using composition. Keep a phone_numbers
table w/ phone_number_id
, the users
table w/ user_id
, and then a customer_phone_numbers
table that maps user_ids to phone_number_ids. Then your PHP code would do something like this:
<?php
$user->save(); // save normal user data
$phoneNumbers = array();
foreach($user->getPhoneNumbers() as $phoneNumber) {
$phoneId = getPhoneNumberId($phoneNumber); // get the phone number, or save a new record if necessary, and return that number
$phoneNumbers[] = $phoneId;
}
$user->savePhoneNumbers( $phoneNumbers ); // adds or removes phone numbers as necessary
EDIT: Based on your feedback, it doesn't sound so much like you are just looking for a way to associate the data. If I understand you correctly, the user will sign up for your website via their phone, then later register on the website. You want to combine the two registrations when this happens.
Are users creating a complete profile from their phone? Do you have a process in place to verify that the phone number provided by the user is actually theirs?
If the user is not creating a full profile via the phone, it sounds like there are two types of "profiles" being stored, a complete website profile, and a telephone profile. This way, you would have a phone profile w/ a phone_profile_id
and a regular user record w/ a user_id
. Then, let users verify their telephone information and associate them to a phone_profile_id
using a composition table as above.
Is that a little closer?
Thanks,
Joe