Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose that you would have tables Athletes, Activities and Scores in your PostgreSQL database. How would you build a query to retrieve the information requested

Suppose that you would have tables Athletes, Activities and Scores in your PostgreSQL database. How would you build a query to retrieve the information requested at the end of the second page? Write down the code based on the given information of the tables themselves, where are given attributes (columns), keys and everything needed. image text in transcribed

image text in transcribed

SQL Form code that would solve the following request Suppose you have these 3 tables in your database: CREATE TABLE Athletes ( IDINT, name VARCHAR (50), gender CHARCI), height FLOAT, PRIMARY KEY (ID) CREATE TABLE Activities ( ID INT name VARCHAR (50), record FLOAT PRIMARY KEY (ID) UNIQUE (name) CREATE TABLE Scores athleteID INT, activity ID INT, result FLOAT, PRIMARY Key (athlete Io, activity ID), FOREIGN KEY (athlete IA) REFERENCES Athletes (I) FOREIGN KEY (activity, IO) REFERENCES Activities (TO) ); Now write PostgreSQL commands that you think. would work in order to retrieve the information requested below. You should malce the querie as simple as you possible can. - The I) and name of each athlete that has at least 5 results in one of the activities that goes by the name "100 m dashs, their best result, along with the difference between the record and their best result, the second to last column should be named "best" while the last column should be nameol ce difference". Also the last column should be formatted to show at least 1 digit before the decimal point and exactly 2 digits after the decimal point

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

Students also viewed these Databases questions