Consider the following schema: CREATE TABLE Player ( name varchar(50) PRIMARY KEY, birthdate date ); CREATE...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following schema: CREATE TABLE Player ( name varchar(50) PRIMARY KEY, birthdate date ); CREATE TABLE Tournament ( name varchar(50) PRIMARY KEY, prize int ); CREATE TABLE Match ( winner varchar(50) REFERENCES player (name), loser varchar(50) REFERENCES player (name), tournament varchar(50) REFERENCES tournament (name), played on date NOT NULL, UNIQUE (winner, loser, tournament), CHECK (loser != winner) ); Assume the following insert commands have been executed: INSERT INTO Player VALUES ('Sofia', '12/13/1987'); INSERT INTO Player VALUES ('Renata', '3/2/1992'); INSERT INTO Tournament VALUES ('Championship', 1000); INSERT INTO Tournament VALUES ('Semi-final', 200); a. (4 pts) Write two INSERT statements for the Match table that satisfy all constraints. b. (8 pts) Write four INSERT statements that each violate a different constraint of the Match table. Assume your statements from (a) have already been executed. 19. For these subquestions, you should write or draw out the table you would expect to get as a result. You are given the following tables Census and Weather: Census city Seattle Seattle Iyear 2020 2010 San Francisco 2010 Dallas 2020 San Francisco 2020 Philadelphia 2020 2020 Denver Weather city Seattle ann rainfallann_cloudy_days 37.0 Los Angeles 11.7 San Francisco 25.0 Dallas 39.1 Boston 43.0 41.5 17.0 Philadelphia population 738200 610700 805500 1303000 870000 1601000 735500 Denver 226 103 105 133 164 160 120 Census.city is foreign key to Weather.city a. (8 pts) What outputs will result from the following query? SELECT c1.city, c2.population - c1.population AS popdiff, w.ann_rainfall FROM Census c1, Census c2, Weather w WHERE c1.city = c2.city AND c1.city = w.city AND c2.year - c1.year = 10 ORDER BY change DESC; BONUS: (5 pts) What outputs will result from the following query? WITH pop2020 AS ( SELECT * FROM Census WHERE year = 2020 ), pop2010 AS ( SELECT * FROM Census WHERE year 2010 ), diff AS ( SELECT p1.city, p1.population p2.population AS pop_diff FROM pop2020 p1 LEFT JOIN pop2010 p2 ON p1.city=p2.city SELECT * FROM diff d LEFT JOIN Weather w ON d.city= w.city; Consider the following schema: CREATE TABLE Player ( name varchar(50) PRIMARY KEY, birthdate date ); CREATE TABLE Tournament ( name varchar(50) PRIMARY KEY, prize int ); CREATE TABLE Match ( winner varchar(50) REFERENCES player (name), loser varchar(50) REFERENCES player (name), tournament varchar(50) REFERENCES tournament (name), played on date NOT NULL, UNIQUE (winner, loser, tournament), CHECK (loser != winner) ); Assume the following insert commands have been executed: INSERT INTO Player VALUES ('Sofia', '12/13/1987'); INSERT INTO Player VALUES ('Renata', '3/2/1992'); INSERT INTO Tournament VALUES ('Championship', 1000); INSERT INTO Tournament VALUES ('Semi-final', 200); a. (4 pts) Write two INSERT statements for the Match table that satisfy all constraints. b. (8 pts) Write four INSERT statements that each violate a different constraint of the Match table. Assume your statements from (a) have already been executed. 19. For these subquestions, you should write or draw out the table you would expect to get as a result. You are given the following tables Census and Weather: Census city Seattle Seattle Iyear 2020 2010 San Francisco 2010 Dallas 2020 San Francisco 2020 Philadelphia 2020 2020 Denver Weather city Seattle ann rainfallann_cloudy_days 37.0 Los Angeles 11.7 San Francisco 25.0 Dallas 39.1 Boston 43.0 41.5 17.0 Philadelphia population 738200 610700 805500 1303000 870000 1601000 735500 Denver 226 103 105 133 164 160 120 Census.city is foreign key to Weather.city a. (8 pts) What outputs will result from the following query? SELECT c1.city, c2.population - c1.population AS popdiff, w.ann_rainfall FROM Census c1, Census c2, Weather w WHERE c1.city = c2.city AND c1.city = w.city AND c2.year - c1.year = 10 ORDER BY change DESC; BONUS: (5 pts) What outputs will result from the following query? WITH pop2020 AS ( SELECT * FROM Census WHERE year = 2020 ), pop2010 AS ( SELECT * FROM Census WHERE year 2010 ), diff AS ( SELECT p1.city, p1.population p2.population AS pop_diff FROM pop2020 p1 LEFT JOIN pop2010 p2 ON p1.city=p2.city SELECT * FROM diff d LEFT JOIN Weather w ON d.city= w.city;
Expert Answer:
Answer rating: 100% (QA)
Starting with question 18 a To write two INSERT statements for the Match table that satisfy all constraints we must ensure The winner and loser are distinct and reference the names in the Player table ... View the full answer
Related Book For
Introduction To Java Programming And Data Structures Comprehensive Version
ISBN: 9780136520238
12th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these databases questions
-
a. Purchased $133,800 of materials. b. Used $94,100 of direct materials in production. c. Incurred $184,480 of direct labor wages. d. Incurred $215,200 of factory overhead. e. Transferred $425,880 of...
-
For each of the following notes receivable held by Winter Company, determine the interest revenue to be reported on the income statements. Round answers to nearest whole dollar. (answers on next...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Locate the centroid of the region bounded by the given curves. about x = 5, y = 2x2, y = 0, x = 5 < UseHorizontal ElementOf Area > x = 5 y = 2x? y = 0
-
If an initial amount A0 of money is invested at an interest rate i compounded times a year, the value of the investment after t years is
-
All candidates applying for a management trainee position are given a personality test that measures the five dimensions in the five-factor model. Which personality traits would you consider to be...
-
Describe the various types of damages that can be awarded to the plaintiff.
-
Consider the following data related to the financial performance of Royal Company. Between 2009 and 2012, income increased by 63 percent, showing a significant increase in income each year. In light...
-
What role does strategic foresight play in shaping strategic planning processes, particularly in anticipating and adapting to disruptive technological advancements, regulatory shifts, and...
-
Although the company has already established medical and retirement plan benefits, Toni Prevosti wants to consider other benefits to attract employees. As the companys accountant, you have been...
-
Consider a single station processing center. The machine has a processing time of 45 seconds, and the operator has a service time of 98 seconds. The machine has a storage capacity of 100 parts and a...
-
Forrer was an employee of Sears for many years. He eventually left because of health problems and began operating a farm. Sears persuaded Forrer to return to work on a part-time basis, and about one...
-
Jackson, a widow who was desperate for money, sold land to her brother, Seymour, for $275. Later, Seymour found valuable timber on the land and sold some of it for $2,353. When Jackson realized that...
-
The table contains price and quantity information for two vehicle models produced by Ford Motor Company, the F-series trucks and Escape SUVs. a. Calculate the amount contributed by Ford to U.S. GDP...
-
The act of canceling a voidable contract. a. abandonment b. age of majority c. contractual c apacity d. competent pa rty e. disaffi rmance f. emancipation g. incompetency h. minor i. necessaries j....
-
An agreement with a person who is required to have, but lacks, the approval of the state to practice his or her business, profession, or o ccupation. a. champerty b. franchisee c. franchisor d....
-
When a person is talking in a small room, the sound intensity level is 60dB everywhere within the room. When there are eight people talking in similar manner simultaneously in the same room, what is...
-
What mass of H2 will be produced when 122 g of Zn are reacted? Zn(s) + 2HCl(aq) ( ZnCl2(aq) + H2(g)
-
Write the following method that returns a random number between start and end, excluding the numbers. public static int getRandom(int start, int end, int... numbers) For example, invoking...
-
Rewrite Programming Exercise 33.1 using RMI. You need to define a remote interface for computing monthly payment and total payment. Data from Programming Exercise 33.1 Write a server for a client....
-
Rewrite Exercise 5.8 to display at most two digits after the decimal point for the temperature using the DecimalFormat class. Data from Exercise 5.8 Write a program that prompts the user to enter the...
-
The following figures relate to the production of product X: If the years production is 20,000 units and this product uses 25 per cent of total factory production, the unit cost for product X in...
-
A company buys and sells units of product P as follows: Under a FIFO method, the gross profit on the sold item is: A. :20. B. :24. C. :25. D. :30. 1 January buy 2 at 30 1 February 1 March buy 3 at 40...
-
If the company in 10b uses the weighted average method, the gross profit is: A. :20. B. :24. C. :25. D. :30.
Study smarter with the SolutionInn App