I am looking to find the best practice for many to many mapping in database.
For example I have two tables to be mapped. I create third table to store this mapping.

On UI I have several A to be mapped(or not) multiple with B. And I see two solutions for now:
1 – On every update for every record from A I will delete all mapped data for it and insert new data mapping.
- Advantage: I store only mapped data.
- Disadvantage: I need to use delete and insert statement every time.
2 – I need to add new bit column to AB table with name isMapped. And I will store all mapping for every record from A to every record from B. On save mapping action I will use only update statement.
- Advantage: No need to delete and insert every time.
- Disadvantage: Need to store unnecessary records.
Can you offer me best solution?
Thanks
between the 2 options you have listed I would go with option no 1, isMapped is not meaningful, if they are not mapped the records should not exists in the first place.
you still have one more option though:
if these are a lot of maps I would delete and insert from the new mapping, otherwise I would just delete all then insert like you are suggesting.