0

I am making up exercises for myself and stumbled across this question:

Given this example relation:

Person(name, birthyear)

Find the relational algebra expression to find the youngest person per name. For example, you have the entries:

(A, 1), (A,2), (B,3), (B,4), (C,5), (C,6)

Expression returns:

(A,1), (B,3), (C,5)

My solution:

ρ p1 (Person) - σ p1.name = p2.name AND p1.birthYear > p2.birthYear (ρ p2 (Person))

Do I accomplish my goal? So yes, will I have doubles and how to elliminate them if I do?

Thanks in advance,

user2092743
  • 351
  • 1
  • 4
  • 11
  • Please give a reference to which of the many versions of "relational algebra" you are using. And: A relation is a set of rows. A value can't be in a set twice. So no duplicates. And: You need a join. See [this answer](http://stackoverflow.com/a/33952141/3404097) and [this answer that it links to](http://stackoverflow.com/a/24425914/3404097). – philipxy Jun 12 '16 at 10:49
  • PS Read about [mcve]s: work through an example and include it. Check out [RelaX](http://138.232.66.66/ra/). – philipxy Jun 12 '16 at 11:15

0 Answers0