Database refactoring, and event/avatar logic adding

Signed-off-by: Kim Seonghyun <shyeon.kim@scipi.net>