How to get values ​​that are repeated in a relationship attribute?

So I have a relation:

Cars (model, passenger)

All models are unique, say, {A, B, C, D, E}.

Passengers are simply the ability of a car (any positive nonzero integer), say, {1,2,2,3,3}

Model|Passenger
A    |1
B    |2
C    |2
D    |3
E    |3

I need to find an expression of relational algebra that will provide opportunities for more than one car. Thus, with the above examples, the expression should return {2, 3}, since they appear more than once for different vehicles.

I have a strong tendency to think that the expression will use some kind of connection, but I cannot figure out how to do this.

+4
2

:

(, ), .

CARS2(model,passenger)≔ρ_(m,p) (CARS)
Answer (passenger)≔π_passenger (CARS⋈_(model ≠ m AND passenger=p) CARS2)
+1

, -

π Passenger σ Count(Model) >= 2 G Passenger (Table1)

, JOIN

SELECT passenger
  FROM table1
 GROUP BY passenger
HAVING COUNT(model) >= 2

:

| PASSENGER |
|-----------|
|         2 |
|         3 |

SQLFiddle

0

All Articles