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

Let's fix the spelling on 'Foreign'.