0

I am a philosopher and am doing my first steps in relational algebra. So here is a puzzle:

Let say that we have a relation R with attributes 'R.a' and 'R.b'. Is it possible to make a renaming and natural join operations on R and receive a triple (a, b, a) as a result?

If I make the following steps:

  1. rename R to S.
  2. rename all attributes in S to 'S.a', 'S.b'.
  3. rename 'S.b' on 'R.b' and
  4. make a natural join of R and S.

Will it work? How do I write such a request properly?

  • 2
    So essentially you want to make a self-join on column b? – ypercubeᵀᴹ Jul 31 '18 at 19:37
0
  1. Rename R to S
  2. Rename S.a to S.c
  3. Natural join T = R |><| S
  4. Rename T.c to T.a

ρc/a((ρa/c(ρR/S)) |><| R)

SQL code look like this:

SELECT R.a, R.b, S.c AS a 
  FROM R
NATURAL JOIN ( SELECT b, a AS c
                 FROM R
             ) AS S
; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.