Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) (30 pts) Consider the following database schema: Employee-(ename, setof(Child

ID: 3715370 • Letter: 1

Question

1) (30 pts) Consider the following database schema: Employee-(ename, setof(Children), Address, setof(Skills)) Children scl, c2,...; Address (city, state, zipcode) Skills -s, s2 Assume that attributes of type setof(Children) and setof(Skills) have attribute names childrenSet and skillsSet. Suppose a database contains a relation emp (Employee) Now answer the following: a) b) c) d) Write a query to unnest the emp relation into flat-emp relation. Write a query to nest the relation flat-emp on the attribute for Children. Write a query to nest the relation flat-emp on the attribute for Skills. Write a query to nest the relation flat-emp on both the attributes for Children and Skills.

Explanation / Answer

a) select ename, children, Address.city, Address.state, Address.zipcode, skills

from emp as flat-emp, flat-emp.setof(Children) as children, flat-emp.setof(Skills) as skills

b) select ename, set(children) as setof(Children), (city, state, zipcode) as Address, skills

from flat-emp

groupby ename, Address, skills

c) select ename, children, (city, state, zipcode) as Address, set(skills) as setof(Skills)

from flat-emp

groupby ename, children, Address

d) select ename, set(Children) as setof(Children), (city, state, zipcode) as Address, set(skills) as setof(Skills)

from flat-emp

groupby ename, Address