sql - Find all descendants -


so studying midterm , stuck on parts 1 , 3 of practice question.

consider following relation:

family(parent, child, childdob)

the intent tuple (p,c,d) means parent p has child c, born on
date d. may assume parents not have 2 children of same name,
, there no twins; i.e., no parent has 2 or more children born on same day. here 3 queries might ask data:

i. find each parent, youngest child, i.e., set of (p,c) such p has
child c, , no other child of p has smaller date of birth c does.

ii. find set of great grandparents of “amy.”

iii. find descendants of “mike.”

which of above queries expressible in relational algebra?

so far first 1 have this:

select family group parent 

so know have groups of parents don't know how select youngest child

i got second 1 using 2 subqueries, third 1 don't think can again because there no guarantee on how many generations descendants span, i'm stuck on 1 don't have 1 yet

for last part can expressed relational algebra...is of them? can sql translated relational algebra?

any appreciated


Comments