Refactoring of event SQL model