Wednesday, 15 May 2013

database - How to get the values that are repeated in an attribute of a relation? -



database - How to get the values that are repeated in an attribute of a relation? -

so have relation:

cars(model, passenger)

the models unique, let's say, {a, b, c, d, e}.

passengers capacity of auto (any positive non-zero integer), let's {1,2,2,3,3}

model|passenger |1 b |2 c |2 d |3 e |3

i need find relational algebra expression yield capacities occur more 1 vehicle. illustration values above, look should homecoming {2, 3} since appear more 1 time different vehicles.

i have strong inclination think look utilize bring together of sort can't figure out how it.

i figured out:

assuming existing relation cars(model, passenger) contains of cars in question , passenger capacities.

cars2(model,passenger)≔ρ_(m,p) (cars) reply (passenger)≔π_passenger (cars⋈_(model ≠ m , passenger=p) cars2)

database database-schema relational-algebra

No comments:

Post a Comment