added sql script for join tables and event business logic