Design: What is the best approach to updating part of a database record?
<p>This question concerns the best design approach rather than a particular technical technique. I have a database table that contains system user's details i.e: username, password, firstname, lastname (these attributes can only be changed by an administrator). The rest of the user record contains address, phone number, mobile number, etc (these attributes can only be changed by the user).</p>

<p>I therefore need 2 forms, an 'admin' form and a 'user' form, with a different set of editable fields on each, and appropriate role-based security to control usage.</p>

<p>Here are two approaches I could take:</p>

<p>Approach 1. Each form has it's own backing bean representing just the editable fields on the form. On 'Save', the backing bean calls a specific DAO method (e.g. UpdateUser_Admin or UpdateUser_User) to perform a partial update of the user record. This approach therefore involves 2 forms, a backing bean for each form, and 2 methods in the DAO class.</p>

<p>Approach 2. There are 2 forms as before, but each form re-creates the entire User object through the use of input fields for the editable fields and hidden fields for the non-editable fields. Both forms would use the same backing bean representing ALL of the User attributes. There would only need to be one method in the DAO - to update ALL fields in the User record.</p>

<p>The second approach seems to make sense to me, but I'm new to development and I'd be grateful if readers could advise if I'm missing something. I've already considered splitting the User table into 2 separate tables but that is not practical in this case. Thank you for your advice.</p>