Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Schema The schema below represents data for the 2018 FIFA World Cup, where people can buy tickets for matches they would like to attend. It
Schema The schema below represents data for the 2018 FIFA World Cup, where people can buy tickets for matches they would like to attend. It attempts to represent the domain well, but in order to keep the assignment manageable, some things are simplified and other details are not represented. For example, the different stages of the competition are ignored and only matches between any two countries are considered Remember that all your queries will be written with respect to the schema below. Your goal is to produce answers that are correct with respect to this schema, even if they aren't quite correct in the real world Relations Team(country, coach) A tuple in this relation represents the team of a country that participates in the competition. country is the team's country name, and coach is the name of the team's coach . Player(PID, fname, lname, position, goals, country) A tuple in this relation represents a football player who is participating in the contest. PID is the player's ID, fname is their first name, Iname is their last name, position is the positioin they are playing on the pitch, goals is the number of goals the player has scored so far in the competition, and country is the country of the team they are playing for. Stadium(SID, capacity, city) A tuple in this relation represents a stadium where a match takes place. SID is the stadium's ID, capacity is the capacity of the stadium, and city is the city where the stadium is located Match(MID, date, time, SID) A tuple in this relation represents a match. MID is the id of the match, date is the date the match is scheduled on, time is the time the match is scheduled on, and SID is the SID of the stadium where the match takes place. . Ticket (TID, datelssued, timelssued, MID) A tuple in this relation represents a ticket that was purchased. TID is the ticket's id, datels- sued is the date that it was purchased, timelssued is the time that it was purchased, and MID is the MID of the match it was purchased for . Competes(MID, countryl, country2, goals1, goals2) A tuple in this relation represents which teams are competing in a match. MID is the id of the match, countryl is the country of the first team, country2 is the country of the second team, goals 1 is the number of goals scored by the first team, and goals2 is the number of goals scored by the second team Player country] Team country] Match SID StadiumSID] Ticket MID C Match MID Competes MID] Match MID Competes(countryl] C Team[country] Competes[cou ntry2] C Team[country] Write the queries below in relational algebra. There are a number of variations on relational algebra, and different notations for the operations. You may use only the operations defined in Section 2.4 of the text and you must use the same notation as in the textbook. In particular, assume all relations are sets (not bags), and do not use any of the extended relational algebra operations from Chapter 5 (for example, do not use the extended projection) Some of the queries cannot be expressed in the language that you are using. In those cases, simply write "cannot be expressed". Later in the course, when we learn SQL, it will be interesting to consider whether they can be expressed in SQL You are encouraged to use the assignment operator to define intermediate results, and it is a good idea to add commentary explaining what you're doing before each expression. This way, even if your final answer is not completely correct, you may receive partial marks. You should assume that both the original constraints enforced by the schema and the addi- tional ones given in Part 1 hold for the following queries. However, do not make any assumptions other than those. Your queries should work for any database that satisfies those constraints. Note: These queries are not in order according to difficulty. 1. Report the country of the team that has played in every stadium. If there are ties report all of them. 2. Report the MID of the match for which the highest number of tickets was purchased. If there are ties report all of them. 3. Report the PID(s) of the player(s) of the team(s) that didn't play in any match. 4. Report the SID(s) of the stadium(s) where exactly one match took place. 5. Report the coaches of the teams with the highest difference in the number of goals when 6. Report the fname and Iname of the players whose position is 'D' and have scored the largest 7. Find the winner country of the match for which the very first ticket out of all the tickets in 8. Report the fname and Iname of the player of the country 'Spain' with the second largest competed with each other at a match. If there are ties, report all of them. number of goals among all players (in any team) who play at the same position. the database was purchased. If there was a tie in the match, report nothing. number of goals among players of that countiry 9. Report the MID(s) of the matches for which at least two tickets were bought on the date of the match. 10. Consider all teams that have won at least one match. For each of these teams, report its country, the position of its player with the largest number of goals and the number of goals he/she has scored. Schema The schema below represents data for the 2018 FIFA World Cup, where people can buy tickets for matches they would like to attend. It attempts to represent the domain well, but in order to keep the assignment manageable, some things are simplified and other details are not represented. For example, the different stages of the competition are ignored and only matches between any two countries are considered Remember that all your queries will be written with respect to the schema below. Your goal is to produce answers that are correct with respect to this schema, even if they aren't quite correct in the real world Relations Team(country, coach) A tuple in this relation represents the team of a country that participates in the competition. country is the team's country name, and coach is the name of the team's coach . Player(PID, fname, lname, position, goals, country) A tuple in this relation represents a football player who is participating in the contest. PID is the player's ID, fname is their first name, Iname is their last name, position is the positioin they are playing on the pitch, goals is the number of goals the player has scored so far in the competition, and country is the country of the team they are playing for. Stadium(SID, capacity, city) A tuple in this relation represents a stadium where a match takes place. SID is the stadium's ID, capacity is the capacity of the stadium, and city is the city where the stadium is located Match(MID, date, time, SID) A tuple in this relation represents a match. MID is the id of the match, date is the date the match is scheduled on, time is the time the match is scheduled on, and SID is the SID of the stadium where the match takes place. . Ticket (TID, datelssued, timelssued, MID) A tuple in this relation represents a ticket that was purchased. TID is the ticket's id, datels- sued is the date that it was purchased, timelssued is the time that it was purchased, and MID is the MID of the match it was purchased for . Competes(MID, countryl, country2, goals1, goals2) A tuple in this relation represents which teams are competing in a match. MID is the id of the match, countryl is the country of the first team, country2 is the country of the second team, goals 1 is the number of goals scored by the first team, and goals2 is the number of goals scored by the second team Player country] Team country] Match SID StadiumSID] Ticket MID C Match MID Competes MID] Match MID Competes(countryl] C Team[country] Competes[cou ntry2] C Team[country] Write the queries below in relational algebra. There are a number of variations on relational algebra, and different notations for the operations. You may use only the operations defined in Section 2.4 of the text and you must use the same notation as in the textbook. In particular, assume all relations are sets (not bags), and do not use any of the extended relational algebra operations from Chapter 5 (for example, do not use the extended projection) Some of the queries cannot be expressed in the language that you are using. In those cases, simply write "cannot be expressed". Later in the course, when we learn SQL, it will be interesting to consider whether they can be expressed in SQL You are encouraged to use the assignment operator to define intermediate results, and it is a good idea to add commentary explaining what you're doing before each expression. This way, even if your final answer is not completely correct, you may receive partial marks. You should assume that both the original constraints enforced by the schema and the addi- tional ones given in Part 1 hold for the following queries. However, do not make any assumptions other than those. Your queries should work for any database that satisfies those constraints. Note: These queries are not in order according to difficulty. 1. Report the country of the team that has played in every stadium. If there are ties report all of them. 2. Report the MID of the match for which the highest number of tickets was purchased. If there are ties report all of them. 3. Report the PID(s) of the player(s) of the team(s) that didn't play in any match. 4. Report the SID(s) of the stadium(s) where exactly one match took place. 5. Report the coaches of the teams with the highest difference in the number of goals when 6. Report the fname and Iname of the players whose position is 'D' and have scored the largest 7. Find the winner country of the match for which the very first ticket out of all the tickets in 8. Report the fname and Iname of the player of the country 'Spain' with the second largest competed with each other at a match. If there are ties, report all of them. number of goals among all players (in any team) who play at the same position. the database was purchased. If there was a tie in the match, report nothing. number of goals among players of that countiry 9. Report the MID(s) of the matches for which at least two tickets were bought on the date of the match. 10. Consider all teams that have won at least one match. For each of these teams, report its country, the position of its player with the largest number of goals and the number of goals he/she has scored
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started