Ewa,
first of all welcome to the world of HANA, UI5, Fiori, etc.
In my experience with HANA, UI5, Fiori, etc.. here are a few suggestions
1) I see you already have the part where you insert a record - great job! I suggest you move your sql code from the xjslib into a stored procedure - (database design time object, .hdbprocedure)
2) the issue you have is to use the inserted record - reference key - for your next insert on the intersection table. here I would suggest you use a sequence (database design time object - .hdbsequence) and from within the stored procedure you could a) get the next value in the sequence, d) use it in the insert and then the generated ID could be used as a reference for your next insert.
I suggest you look into the HANA developer guide and also look at more posts here to
a) become familiar with the database design time objects
b) become familiar how to call stored procedures from your xsjslib - here is a blog:
3) once you have made the update, your UI could refresh by calling your xsodata again
here are some other tutorials : http://help.sap.com/saphelp_hanaplatform/helpdata/en/1e/109b2e781941f7836110eca2c84df3/content.htm?frameset=/en/34/29fc63a1de4cd6876ea211dc86ee54/frameset.htm¤t_toc=/en/34/29fc63a1de4cd6876ea211dc86ee54/plain.htm&node_id=372&show_children=false
you can also check out you tube - hana academy
hope this is a good direction and somewhat helpful