Fall2017.assignment2.solution.pdf - Assignment 2 Solution 1...

Info icon This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Assignment​ ​2​ ​Solution 1. SELECT​ ​studio.name,​ ​songExec.name FROM​ ​Studio,​ ​SongExec,​ ​Songs,​ ​Singers WHERE​ ​Studio.presC#​ ​=​ ​SongExec.cert#​ ​AND​ ​Studio.name​ ​=​ ​Songs.studioName AND​ ​Songs.title​ ​=​ ​Singers.songTitle​ ​AND​ ​Songs.year​ ​=​ ​Singers.songYear AND​ ​Singers.singerName​ ​=​ ​“Taylor​ ​Swift” 2. SELECT​ ​DISTINCT​ ​s1.singerName FROM​ ​Singers​ ​AS​ ​s1,​ ​Singers​ ​AS​ ​s2 WHERE​ ​s1.songTitle​ ​=​ ​s2.songTitle​ ​AND​ ​s1.songYear​ ​=​ ​s2.songYear AND​ ​s1.songYear​ ​>=​ ​2010​ ​AND​ ​s1.songYear​ ​<=​ ​2017 AND​ ​s2.singerName​ ​=​ ​“Taylor​ ​Swift”​ ​AND​ ​s1.singerName​ ​<>​ ​“Taylor​ ​Swift” 3. (SELECT​ ​singerName FROM​ ​Singers​ ​AS​ ​S1) EXCEPT (SELECT​ ​singerName FROM​ ​Singers​ ​AS​ ​S2,​ ​Songs WHERE​ ​S2.songTitle​ ​=​ ​title​ ​AND​ ​S2.songYear​ ​=​ ​year AND​ ​studioName​ ​=​ ​“Sony”​ ​AND​ ​year​ ​=​ ​2017) 4. SELECT​ ​DISTINCT​ ​singerName FROM​ ​Singers WHERE​ ​NOT​ ​EXISTS​ ​(​ ​SELECT​ ​* FROM​ ​Songs WHERE​ ​songTitle​ ​=​ ​title​ ​AND​ ​songYear​ ​=​ ​year AND​ ​studioName=​ ​“Sony”​ ​AND​ ​year​ ​=​ ​2017 ) 5. SELECT​ ​songTitle FROM​ ​Singers GROUP​ ​BY​ ​songTitle HAVING​ ​COUNT(songTitle)>=2 another​ ​correct​ ​solution SELECT​ ​s1.title FROM​ ​Songs​ ​s1,​ ​Songs​ ​s2 WHERE​ ​s1.title​ ​=​ ​s2.title​ ​AND​ ​s1.year​ ​<​ ​s2.year 6. SELECT​ ​COUNT(s.title) FROM​ ​Singers​ ​sg,​ ​Song​ ​s WHERE sg.songTitle = s.title AND sg.songYear = s.year AND s.studioName = ‘Sony’ AND sg.singerName​ ​=​ ​‘Katy​ ​Perry’ 7. SELECT​ ​SongExec.name,​ ​COUNT(*) FROM​ ​SongExec,​ ​Songs,​ ​Singers WHERE​ ​procducerC#​ ​=​ ​cert#​ ​AND​ ​singerName​ ​=​ ​“Bruno​ ​Mars“ AND​ ​songTitle​ ​=​ ​title​ ​AND​ ​songYear​ ​=​ ​year GROUP​ ​BY​ ​SongExec.name 8. (SELECT​ ​sg1.singerName​ ​FROM​ ​Songs​ ​s1,​ ​Singers​ ​sg1 WHERE sg1.songTitle = s1.title AND sg1.songYear = s1.year AND s1.studioName = ‘Sony’) EXCEPT (SELECT​ ​sg2.singerName​ ​FROM​ ​Songs​ ​s2,​ ​Singers​ ​sg2 WHERE sg2.songTitle = s2.title AND sg2.songYear = s2.year AND s2.studioName <> ‘Sony’) 9. SELECT​ ​st.name,​ ​se.name FROM​ ​Studio​ ​st,​ ​SongExec​ ​se WHERE​ ​st.pres#​ ​=​ ​se.cert# AND​ ​NOT​ ​EXISTS​ ​( SELECT​ ​s.title,​ ​s.year FROM​ ​Songs​ ​s WHERE​ ​s.studioName​ ​=​ ​st.name ) EXCEPT​ ​( SELECT​ ​sg.songTitle,​ ​sg.songYear FROM​ ​Singers​ ​sg WHERE​ ​sg.singerName​ ​=​ ​‘Selena​ ​Gomez’ ) 10. SELECT​ ​SongExec.name FROM​ ​SongExec​ ​AS​ ​E1,​ ​Studio​ ​AS​ ​S1 WHERE​ ​E1.cert#​ ​=​ ​S1.presC#​ ​AND networth​ ​>​ ​(SELECT​ ​AVG(networth) FROM​ ​SongExec​ ​AS​ ​E2,​ ​Studio​ ​AS​ ​S2 WHERE​ ​E2.cert#​ ​=​ ​S2.presC#) ...
View Full Document

  • Fall '08
  • Yang,J
  • It

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern