I have a question involving relational algebra. Suppose I have two relations A and B, where B has a foreign key that references A.

Using relational algebra, how do I select all tuples from A where variable X exists in B? Example:

Relation 1


Relation 2


How do I select from Cars, all the tuples where id exists in Ford? Example:

Cars  car_id  model
       1    a
       2    b
       3    c

Ford  car_id   year
      1        2000
      3        2002

What I would like is: select all from cars where id exists in Ford, which returns:

Result:  car_id  model
         1    a
         3    c

1 Answer 1


The (somewhat trivial) answer seems to be:

Cars ⋉ Ford

Relational algebra, semijoin (Wikipedia)

Alternatively (in response to a comment):

πR(R ⋈ S)

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