As in Quiz10, assume we have this database: CREATE TABLE 'country' ( 'Code' CHAR (3) NOT...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
As in Quiz10, assume we have this database: CREATE TABLE 'country' ( 'Code' CHAR (3) NOT NULL DEFAULT" 'Name' CHAR (52) NOT NULL DEFAULT", CECS 535: Introduction to Database Fall 2023, Homework 5 'Continent' enum ('Asia', 'Europe', 'North America', 'Africa', 'Oceania', 'Antarctica', 'South America') NOT NULL DEFAULT 'Asia', 'Region' CHAR (26) NOT NULL DEFAULT", 'SurfaceArea' DECIMAL NOT NULL DEFAULT '0.00', 'GNPOld' DECIMAL DEFAULT NULL, 'LocalName' CHAR (45) NOT NULL DEFAULT", 'GovernmentForm' CHAR (45) NOT NULL DEFAULT"> 'HeadOf State' CHAR (60) DEFAULT NULL, 'Capital INT DEFAULT NULL, 'Code2' CHAR (2) NOT NULL DEFAULT", PRIMARY KEY ('Code')); ); 'IndepYear' SMALLINT DEFAULT NULL, 'Population' INT NOT NULL DEFAULT '0', 'LifeExpectancy' DECIMAL DEFAULT NULL, 'GNP DECIMAL DEFAULT NULL, CREATE TABLE 'city' ( 'ID' INT NOT NULL AUTO_INCREMENT, 'Name' CHAR (35) NOT NULL DEFAULT", 'CountryCode" CHAR (3) NOT NULL DEFAULT'' 'District' CHAR (20) NOT NULL DEFAULT"' 'Population' INT NOT NULL DEFAULT '0', PRIMARY KEY ('ID'), KEY 'CountryCode' ('CountryCode'), FOREIGN KEY ('CountryCode') REFERENCES 'country' ('Code') ); " CREATE TABLE 'countrylanguage ( 'CountryCode' CHAR (3) NOT NULL DEFAULT", 'Language CHAR (30) NOT NULL DEFAULT '' 'IsOfficial' enum ('T', 'F') NOT NULL DEFAULT 'F', 'Percentage' DECIMAL NOT NULL DEFAULT'0.0', PRIMARY KEY ('CountryCode', 'Language), FOREIGN KEY ('CountryCode ) REFERENCES 'country' ('Code') 1 Recall that table city has 10,000 tuples, country has 800 and countrlanguage has 2,500 tuples. Assume you have 20 pages of memory buffer. Pages are 1K (1024 bytes). Assume the query SELECT c. Name, sum (c. Population), avg (co.GNP) FROM city c, country co, countrylanguage cl WHERE c. CountryCode = co. Code and cl.CountryCode=co. Code and Language = 'English' and Continent = 'Asia' and c. Population > 100,000 GROUP BY c. Name; In all the following, explain how you obtain your numbers in order to receive credit. Numbers without explanation will not get credit. 1. Give an initial query tree for this query. 2. Give an optimized query tree for this query. All you have to do is push down projections and selections. 3. To answer some of the following, you will need to calculate the size of country language. Give the size of countrylanguage in blocks/pages. 4. Estimate the cost of selection Population>100,000 (city) assuming selectivity factor of 5%, if (a) the file for table city is a heap, no indices. (b) the file for table city file is sorted on Population. (c) the file for table city has a clustering index on Population with height 4 (each pointer is 8 bytes). (d) the file for table city has a secondary index on Population, with height 6 (each pointer is 8 bytes). 5. Estimate the size and cost of implementing the join country country language. (a) first, give join size in tuples and number of pages/blocks. (b) cost if done by nested loop. (c) cost if done by sort-merge join. (d) cost if done by hash-join. 6. For this expression T country.Code, GNP,city. Name,city. Population (Continent='Asia' (country Code=CountryCode City)) and assuming a selectivity factor the selection of 1 in 7 tuples, (a) Give an estimate of the final size of this expression. Assume the selection has a 10% selectivity factor. (b) Give a query that uses pipeline and pushes down the selection and cost estimate. (c) Give a query plan that does not use pipeline and does not push down the selection, and a cost estimate. (d) Give a query plan that does not use pipeline and does push down the selection, and a cost estimate. 2 As in Quiz10, assume we have this database: CREATE TABLE 'country' ( 'Code' CHAR (3) NOT NULL DEFAULT" 'Name' CHAR (52) NOT NULL DEFAULT", CECS 535: Introduction to Database Fall 2023, Homework 5 'Continent' enum ('Asia', 'Europe', 'North America', 'Africa', 'Oceania', 'Antarctica', 'South America') NOT NULL DEFAULT 'Asia', 'Region' CHAR (26) NOT NULL DEFAULT", 'SurfaceArea' DECIMAL NOT NULL DEFAULT '0.00', 'GNPOld' DECIMAL DEFAULT NULL, 'LocalName' CHAR (45) NOT NULL DEFAULT", 'GovernmentForm' CHAR (45) NOT NULL DEFAULT"> 'HeadOf State' CHAR (60) DEFAULT NULL, 'Capital INT DEFAULT NULL, 'Code2' CHAR (2) NOT NULL DEFAULT", PRIMARY KEY ('Code')); ); 'IndepYear' SMALLINT DEFAULT NULL, 'Population' INT NOT NULL DEFAULT '0', 'LifeExpectancy' DECIMAL DEFAULT NULL, 'GNP DECIMAL DEFAULT NULL, CREATE TABLE 'city' ( 'ID' INT NOT NULL AUTO_INCREMENT, 'Name' CHAR (35) NOT NULL DEFAULT", 'CountryCode" CHAR (3) NOT NULL DEFAULT'' 'District' CHAR (20) NOT NULL DEFAULT"' 'Population' INT NOT NULL DEFAULT '0', PRIMARY KEY ('ID'), KEY 'CountryCode' ('CountryCode'), FOREIGN KEY ('CountryCode') REFERENCES 'country' ('Code') ); " CREATE TABLE 'countrylanguage ( 'CountryCode' CHAR (3) NOT NULL DEFAULT", 'Language CHAR (30) NOT NULL DEFAULT '' 'IsOfficial' enum ('T', 'F') NOT NULL DEFAULT 'F', 'Percentage' DECIMAL NOT NULL DEFAULT'0.0', PRIMARY KEY ('CountryCode', 'Language), FOREIGN KEY ('CountryCode ) REFERENCES 'country' ('Code') 1 Recall that table city has 10,000 tuples, country has 800 and countrlanguage has 2,500 tuples. Assume you have 20 pages of memory buffer. Pages are 1K (1024 bytes). Assume the query SELECT c. Name, sum (c. Population), avg (co.GNP) FROM city c, country co, countrylanguage cl WHERE c. CountryCode = co. Code and cl.CountryCode=co. Code and Language = 'English' and Continent = 'Asia' and c. Population > 100,000 GROUP BY c. Name; In all the following, explain how you obtain your numbers in order to receive credit. Numbers without explanation will not get credit. 1. Give an initial query tree for this query. 2. Give an optimized query tree for this query. All you have to do is push down projections and selections. 3. To answer some of the following, you will need to calculate the size of country language. Give the size of countrylanguage in blocks/pages. 4. Estimate the cost of selection Population>100,000 (city) assuming selectivity factor of 5%, if (a) the file for table city is a heap, no indices. (b) the file for table city file is sorted on Population. (c) the file for table city has a clustering index on Population with height 4 (each pointer is 8 bytes). (d) the file for table city has a secondary index on Population, with height 6 (each pointer is 8 bytes). 5. Estimate the size and cost of implementing the join country country language. (a) first, give join size in tuples and number of pages/blocks. (b) cost if done by nested loop. (c) cost if done by sort-merge join. (d) cost if done by hash-join. 6. For this expression T country.Code, GNP,city. Name,city. Population (Continent='Asia' (country Code=CountryCode City)) and assuming a selectivity factor the selection of 1 in 7 tuples, (a) Give an estimate of the final size of this expression. Assume the selection has a 10% selectivity factor. (b) Give a query that uses pipeline and pushes down the selection and cost estimate. (c) Give a query plan that does not use pipeline and does not push down the selection, and a cost estimate. (d) Give a query plan that does not use pipeline and does push down the selection, and a cost estimate. 2
Expert Answer:
Answer rating: 100% (QA)
1 Initial Query Tree PROJECT AGGREGATE SELECT SELECT SELECTION CROSS PRODUCT JOIN CITY COUNTRY COUNTRYLANGUAGE 2 Optimized Query Tree Pushing down pro... View the full answer
Related Book For
Database Systems Design Implementation and Management
ISBN: 978-1337627900
13th edition
Authors: Carlos Coronel, Steven Morris
Posted Date:
Students also viewed these databases questions
-
Corporations with international operations need to assess the risks associated with setting up and maintaining operations in different regions of the world. Consideration of the risks include...
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
On December 31, 2021, there is a batch of commodities sold under FOB destination conditions in the shipping area, and this batch of commodities is not included in the inventory count middle. There is...
-
Velocity is related to acceleration and distance by the following expression: v2 = 2axp. Find the power p that makes this equation dimensionally consistent.
-
Cornhusker Company provides the following information at the end of 2021. Required: Prepare the income statement, statement of stockholders? equity, and balance sheet for Cornhusker Company on...
-
True or False: Faulty poured aluminum bars are easily found during static testing.
-
An investigation of the effectiveness of an antibacterial soap in reducing operating room contamination resulted in the accompanying table. The new soap was tested in a sample of eight operating...
-
3. A beam section having bD=400mm800mm is required to develop an effective ultimate moment (OM) of 1800kNm. Design the reinforcement using compression steel if necessary. Assume f-32MPa and =500MPa....
-
Mercier Manufacturing produces a plastic part in three sequential departments: Extruding, Fabricating, and Packaging. Mercier uses the weighted-average process costing method to account for costs of...
-
Setting Up and Managing Transactions in Sage 50 for Northern Tech Ltd. Introduction: Northern Tech Ltd. is a Canadian-based retail company specializing in the Electronics and Technology industry. The...
-
Consider cylindrically symmetric solutions to the wave equation (f does not depend on or :). This is a wave emitted by a line source, for example. a) Simplify the 3D wave equation to a 1D (in space)...
-
CHAPTER 1-The BASICS-Assignment 1 The Basics KEY POINTS STEP 1: First Impressions Matter People see you first, hear you second Wear appropriate clothing for the type of work you do Make sure you are...
-
Given the following independent ratios for a) to j), compare 'Company' to the Industry Averages and state (for each ratio) whether 'Company' is performing better or worse than the overall industry:...
-
If you were to win the lotto for 100mil today and were given an option to receive 5.5m for 25 years. Given that interest is currently doing at 3%, which option will you choose? Provide a comparative...
-
Marcy inherited $25,000 and invested part of it in a money market account (x), part in municipal bonds (y), and part in a mutual fund (z). After one year, she received a total of $1,620 in simple...
-
Show by calculation whether the reaction: HC2H3O2(aq) <> H+(aq) + C2H3O2-( aq) G = +27.2 kJ is spontaneous at 25C (a) when [H+] = [C2H3O2-] = 0.85 M; [HC2H3O2] = 0.15 M. (b) when [H+] =...
-
Construct a 4 x 25 design confounded in two blocks of 16 observations each. Outline the analysis of variance for this design.
-
What are the disadvantages of the DDBMS?
-
Create ColdFusion scripts to search, add, edit, and delete records for the USER table in the RobCor database.
-
Discuss the evolution of object-oriented concepts. Explain how those concepts have affected computer-related activities.
-
Suppose a bond is taxable for both federal and state purposes. Let Rb = the BTROR on the bond, tfed = the federal tax rate, and tst = the state tax rate. Determine the ATROR (i.e., after federal and...
-
Under what conditions are the Exempt Model and Pension Model equivalent? Under what conditions would one model perform better than the other? How does the \($6,500\) limitation on deductible and Roth...
-
Consider three taxpayers who are in the following tax brackets: Alice 25% Brad 35% Camille 40%
Study smarter with the SolutionInn App