Relational Algebra First and Last Date -
Relational Algebra First and Last Date -
i started learning database relational algebra, , got stuck on these 2 questions.
the original question more complicated managed narrow downwards , simplify tables below, couldn't figure out how it, help plz.
this interesting, order not concept nowadays in relational algebra. hence have utilize workaround. we're going utilize 2 copies of relation r, i'll phone call 1 x, , other y:
x , y on name attribute, gives relation attributes (x.id, x.date, x.name, y.id, y.date, y.name). i'll phone call joined relation j. select j entries satisfy x.date < y.date. have relation first date donor exists in x.date , lastly date exists in y.date. we take original relation r , project (r.date, r.name) dates donor donated on. finally, obtain relation of first dates, project (y.date, y.name) (which doesn't have first dates), , set difference first dates = (r.date, r.name)\(y.date, y.name). similarly, last dates = (r.date, r.name)\(x.date, x.name). relational-algebra
Comments
Post a Comment