Use the recursion facility of SQL:1999 to express a so-called “same generation” query: Given a Parent relation, ?nd al l pairs of people who have the same ancestor and are removed from her by equal number of generations. (For example, a child is removed from her parent by one generation and from grandparent by two.)

What will be an ideal response?



CREATE RECURSIVE VIEW SameGeneration(Cousin1, Cousin2) AS
SELECT DISTINCT P.Parent, P.Parent
FROM Parent P
UNION
SELECT DISTINCT P.Child, P.Child
FROM Parent P
UNION
SELECT P1.Child, P2.Child
FROM Parent P1, Parent P2, SameGeneration S
WHERE P1.Parent = S.Cousin1 AND S.Cousin2 = P2.Parent


The ?rst two (non-recursive) queries create the initial pairs of the form p, p (certainly, two occurrences of the same person is removed from a common ancestor by the same number of generations). The last, recursive, subquery computes the rest.

Computer Science & Information Technology

You might also like to view...

____________________ view displays contacts as if they were business cards.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

To produce the current date, the ________ is used in Access which is equivalent to the TODAY function in Excel

Fill in the blank(s) with correct word

Computer Science & Information Technology

To display existing text in a table format, use the ________ command

A) Convert Text B) Convert to Table C) Convert Table D) Convert Text to Table

Computer Science & Information Technology

A full backup and an image backup are the same thing.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology