8 Chapter 5 Advanced SQL
with each cell containing the marks for that
course
/
student
for that exam.
Sort the output by rollno. You need not output summary results.
. .
.7
b. Extend the above query to output the crosstab with scaled marks, where the
5.5 Suppose you are given a relation
p
a
r
e
n
t
(
P
,
C), where P is the name of a parent
and C the name of a child of
P
. Assume that names are unique, that is, no two
people have the same name.
a. Write a recursive SQL query to compute all
descendants
of each person, and
record with each descendant the level of descent (1 for child, 2 for grand-
child, etc.). The program should define a view
d
e
s
c
e
n
d
a
n
t
(
A
,
D, L). Here,
A
5.6 a. Give table definitions of
r(A,
B) and s(A, B), with all attributes of type
in-
5.7 Given the relation person(name, sex, father, mother), with name as
the primary key, and sex taking on values ’M’ and ’F’, write recursive views in
5.8 Suppose you are given a relation
p
a
r
e
n
t
(
X
,
Y
) indicating that X is a parent
5.9 Suppose you are given a relation
co
nn
e
c
t
i
o
n
(
X
,
Y,
Dep,
Arr),
where a tuple in
the relation indicates that there is a train from X to
Y
, departing at time
D
e
p