modify file for inserting in two tables and insert the foreign key. Added also a function to generate the id of the event