Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Memebers,

Help Me out with the one question which one of my friend has asked me

There are two tables table1 and table2

Table1 has two columns
colA --primary key
colB-- foreign key

Table2 has two columns
colB--Primary key
colA--foreign key

Table1's colB is dependent on table2's colB
Table2's colA is dependent on table1's colA

Insert operation is to be performed on these tables

How can we perform this operation?
Posted

This is a bad design, foreign keys should only go one way from child to parent.
 
Share this answer
 
Comments
Sandeep Mewara 12-Jun-12 9:31am    
Comment from OP:
Dear Mehdi Gholam,

I know that this is a bad design, but what would be the solution if such kind of problem's occurred.
INSERT INTO table_1(colA,colB) VALUES (1,null)
INSERT INTO table_2(colB,colA) VALUES (1,1)
UPDATE table_1 SET colB=1 WHERE colA=1
 
Share this answer
 
Comments
vikashbk 13-Jun-12 2:34am    
Thanks Harshada,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900