•Write 5 Queries and explain what they would return. Use the database on the pre
ID: 3668026 • Letter: #
Question
•Write 5 Queries and explain what they would return. Use the database on the previous slides. At least two of the queries must contain some form of join.
O Songs Artists O Group_Membership V Song_Id INT Artist _Id INT P Group_Id INT Song_Name VARCHAR(300) O Artist_F_Name VARGHAR(45) Artist Id INT O Song Language V ARCHAR(45) O Artist L_Name VARCHAR(45) Music_Groups O Track _Number INT Group_ID INT I Indexes Group_Name VARCHAR(45) D Albums O Date _Formed DATE Album _Id INT O Studio INT to Album _Name VARCHAR(45) ––– Indexes Creator INT Indexes O Studios Studio_ID INT Name VARGHAR(45) IT IndexesExplanation / Answer
select * from Songs cross JOIN Song_List;
The result is Cartesian product of rows in tables.
2. select * from Songs,Song_List where Songs.Song_Id=Song_List.Song_Id;
This query results in records which are matched on equality.
3.select * from Song_List NATURAL JOIN Albums
It returns the record with matched Album_Id from the tables.
4.select * from Artists full outer join Group_Membership on (Artists.Artist_Id=Group_Membership. Artist_Id );
It returns all matched records from both the tables and then unmatched record s from both tables with null values.
5.select *from Group_Membership Left outer join Music_Groups( Group_membership.GroupId=Music_Groups. Group_Id);
It returns all matched records from both tables and all left table records with null values for table2.fields.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.