How do I reduce repetitive code when inserting the same metadata into identical columns over multiple tables? <p><strong>My goals:</strong></p> <ul> <li>Follow database-normalization.</li> <li>Ability to track changes in my tables.</li> <li>Ability to restore the state of my database from a given point in time, e.g. last month.</li> <li>Separate the code that is processing the data so that the input can come either from a HTML-form or a script in another language (Ruby/perl).</li> </ul> <p>To accomplish this, I've opted for a database design like the one described in this answer:</p> <p><a href="http://stackoverflow.com/questions/12563706/is-there-a-mysql-option-feature-to-track-history-of-changes-to-records">StackOverflow: Is there a MySQL option/feature to track history of changes to records?</a></p> <p>However, when a user updates several fields, the same metadata has to be inserted into multiple tables that contain identical columns, and my code becomes repetitive. </p> <p><strong>Example:</strong></p> <p>A user submits data through a HTML-form. PHP processes the data like below, with the help of Propel ORM.</p> <pre><code>function insertEvent($name, $venueId, $user, $date, $id = 0) { //validation and formatting.. //if id == 0, new event, //else, this is an update, archive the old database row on successful processing and maintain a common id as a parent //... $event = new Event(); $event-&gt;setName($name); $event-&gt;setVenueId($venueId); $event-&gt;setUser($user); //1 $event-&gt;setValidFrom($date); //1 $event-&gt;setValidUntil(null); //1 $event-&gt;save(); // ... } function insertEventPhonenumber($phonenumber, $pid, $user, $date, $id = 0) { //... $event_phonenumber = new EventPhonenumber(); $event_phonenumber-&gt;setPid($pid); //2 $event_phonenumber-&gt;setPhonenumber($phonenumber); $event_phonenumber-&gt;setUser($user); //2 $event_phonenumber-&gt;setValidFrom($date); //2 $event_phonenumber-&gt;setValidUntil(null); //2 $event_phonenumber-&gt;save(); // ... } function insertEventArtistId($artistId, $pid, $user, $date, $id = 0) { //... $event_artistId = new EventArtistId(); $event_artistId-&gt;setPid($pid); //3 $event_artistId-&gt;setArtistId($artistId); $event_artistId-&gt;setUser($user); //3 $event_artistId-&gt;setValidFrom($date); //3 $event_artistId-&gt;setValidUntil(null); //3 $event_artistId-&gt;save(); // ... } </code></pre> <p><strong>My problem:</strong></p> <p>In my full code there are more tables affected than the three in the example.</p> <p>Marked with //1, //2 and //3, you see data input that is often going to be identical.</p> <p>In my stomach, I don't like this. I've been trying search engines with queries like 'common columns in SQL insert queries over multiple tables' and variations of the wording, without finding anything directly related to my problem.</p> <p>Is this bad practice like it feels to me?</p> <p>How can I minimize the repetition in my code?</p>