Then your logic is wrong for storing answer details in result table.
As there is no any answerId in Option table which you will retain as answerId in Result table.
Also if user already attempt the test then only record get inserted so why to add count column if user not attempt the test then there will no any record entry for test.
You need to modify the table definition according to option table also for answer Table. Then you can apply the correct logic in code till then no use to change in code.