title: Flexible MySQL Database Schema to store logs
body: <p>I'm looking for a flexible MySQL database schema to save logs.</p>
  
  <p>Currently I'm using this one (simplified for the example).</p>
  
  <p><img src="https://i.stack.imgur.com/b6NC9.png" alt="Loggin"></p>
  
  <p>Bigger version: <a href="https://i.stack.imgur.com/b6NC9.png" rel="nofollow noreferrer">http://i.stack.imgur.com/b6NC9.png</a></p>
  
  <p>I can do a <code>select * from log</code>, get the log_type and read the specific table.
  If log_type:tag is user, the specific table will be called log_user.</p>
  
  <p>To add logs for an application I will add a tag application into <code>log_type</code> and
  create a new table <code>log_application</code>.</p>
  
  <p>To read all logs for a user, I do a select <code>SELECT * FROM log_user INNER JOIN log ON log_user.logid=log.id WHERE userid=123</code>.</p>
  
  <p>This is actually working very well and flexible I would nevertheless be interested if somebody has a better idea for such a database schema.</p>