rocknbil - 4:41 pm on Feb 27, 2012 (gmt 0)
Seems like the hard way to do it. Why not eliminate the third table and do something like this?
2. the address table
- address id
- state id
... where is_current is a boolean true/false or tinyint 1/0. Then there's no duplication of data (same address info in tables 2 and 3) and in your forms allows the customers (or administrators) to choose which is the current address.
over relying on the last record in the customer_address table
Because the last record, or even the one with the highest unique identifying number, may not **be** the "current address." This is also the reasoning for the above idea, any time you rely on "some condition(s)" to determine an outcome, there's always the possibility you can't forsee all possible conditions that may arise - or they may change. You could even use the is_current as an array value you'd populate:
$addresses = array(
1 => 'current',
2 => 'home',
3 => 'business',
4 => alternate address