286 views
0 votes
0 votes

please explain this ---- how to find the loop using sql

1 Answer

Best answer
1 votes
1 votes
Let's consider two tuples.

(1,2)

(2,1)

The two tuples are forming a loop right? 1-2-1 .

So for this , you need to do a self join and check for which pair of tuples .

t1.Y = t2.X and t2.Y = t1.X

You can print those tuples.

The relation algebra expression is correct.

If it needs to be written in sql , it would be like ,

Select * from Adjacency  A1 , Adjacency A2 on A1.Y = A2.X where A2.Y = A1.X.

Kindly correct me if I went wrong somewhere.
selected by

Related questions

1 votes
1 votes
0 answers
2
garimanand asked Jan 19, 2019
235 views
find the total number of comparisons-for(j=1;j<=n-1;j++){for(k=j+1;k<=n+1;j++){if(A[j]<A[k])A[j]=A[j]+2;}}so my question is do i need to consider for loop condition compa...
0 votes
0 votes
1 answer
3
supriya supugade asked Feb 1, 2017
168 views