database stuff for events