Adding foreing keys management to the sqlite database and the event actions