How to update mutual entries in DB?
- by Sthita
I am not able to perform mutual update to my Database.
My Requirement is like this :
Insert IDS UPDate DB Entries
ID ConnectedTo ID connectedTo connectedVia
2 1 --- No Entry -----
2 3 -- No Entry -----
When ID 1 Comes in to picture (Enties happened to Table)
1 4 1 3 2
1 5 2 4 1
1 2 2 5 1
When ID 3 Comes into picture (Enties happened to Table)
3 4 3 5 1
3 1 ----
3 2 ----
Similarly when ID 4 Comes in to picture
4 9 4 2 3
4 10 4 5 1
4 3 4 2 1
4 1 1 9 4
1 10 4
Its basically Updating the mutual connections.No Duplicate entries should happen. Like for example 2 3 and 3 2 are mutually connected and 1 is associated with them so there is no need to insert (3 2 via 1).
I think this is my requirement. Anything possible combinations i have missed please let me know. i will Update.
Please help me writing the logic or any example using jdbc and java.