Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Questions 3 - 5 For each SQL query below, do the following: Write a query for the pg _ class table to get the number

Questions 3-5
For each SQL query below, do the following:
Write a query for the pg_class table to get the number of pages and tuples in each relation. Show the query and the results. No need to repeat answers if a table is used multiple times in the questions below. That is, for each question, just get information about new tables.
List two types of joins that could be used for the query.
Using the formulas provided in the slides, calculate the cost of doing each type of join listed in b.
Use EXPLAIN to identify which join algorithm postgresql uses. (See Documentation: 14: EXPLAIN Also, see slide 19,20 in Slides 12 for for information about Explain)
Report if your calculation of which join is cheapest matches postgresqls choice or not
Use work_mem /8k to find # of buffer pages available to join (Documentation: 13: 19.4. Resource Consumption)
Question 3(20 points):
SELECT A.first, A.last, A.clearance_id
FROM agent A, securityclearance S
WHERE A.clearance_id = S.sc_id
Question 4(20 points):
SELECT L.language L.lang_id
FROM language L, languagerel LR
WHERE L.lang_id = LR.lang_id;
Question 5(20 points):
SELECT A1.agent_id, A2.agent_id
FROM agent A1, agent A2
WHERE A1.salary > A2.salary

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions

Question

understand the selection bias in contemporary work psychology;

Answered: 1 week ago

Question

What forces are driving the added-value movement in HRM?

Answered: 1 week ago