Please answer a, b, c and d. 1) (30 pts) Consider the following database schema:
ID: 3713055 • Letter: P
Question
Please answer a, b, c and d.
1) (30 pts) Consider the following database schema: Employee-(ename, setof (Children), Address, setof (Skills)) Children-[cl, c2,.., Address (city, state, zipcode) Skills s1, 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) Write a query to unnest the emp relation into flat-emp relation. b) Write a query to nest the relation flat-emp on the attribute for Children. c) Write a query to nest the relation flat-emp on the attribute for Skills. d) Write a query to nest the relation flat-emp on both the attributes for Children and Skills.Explanation / Answer
a)
select ename, C as Children, Address.city, Address.state, Address.zipcode, S as Skills
from emp as E, E.childrenSet as C, E.skillsSet as S
b)
select ename, set(Children) as childrenSet, (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 skillsSet
from flat-emp
groupby ename, Children, Address
d)
select ename, set(Children) as childrenSet, (city, state, zipcode) as Address, set(Skills) as skillsSet
from flat-emp
groupby ename, Address
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.