title: MySQL Trigger - Summarize changes in json formatted column
body: <p>I'm trying to create some triggers for my MySQL tables to keep track of changes. I thought of a table like</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `contacts_changes` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `action` enum('insert','update','delete') NOT NULL,
    `contact_id` int(6) NOT NULL,
    `changes` text NOT NULL,
    PRIMARY KEY (`id`)
  );
  </code></pre>
  
  <p>where contact_id is a foreign key to the table I want to monitor and in column changes I want to store the changes made using the JSON format.</p>
  
  <p>So if I change the familyname and birthday of an entry in the contact table the changes column should contain <code>{"familyname": "Smith", "birthday": "1982-06-24}</code>.</p>
  
  <p>I found a lot of examples for using triggers to track changes but none of them summarizes the changes made in a single column of a single row. What they do is to insert a new row for each change made, i.e. one row for changing the birthday and another for changing the familyname.</p>
  
  <p>Due to my lack of knowledge of the (My)SQL language I failed to figure out if it's possible to do something I had in mind and if it is how it can be done.</p>
  
  <p>Any ideas or hints how to solve this?</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edit:</strong> Posted former edit as answer.</p>