Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is not to be tried in PostgreSql, because there are no data provided. You can write a handmade code solution by what you think

This is not to be tried in PostgreSql, because there are no data provided. You can write a handmade code solution by what you think would work.

- 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 included. You can use select, join, where, whatever 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 (1) 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 os 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 dash", 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 named 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. 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 (1) 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 os 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 dash", 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 named 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

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

Describe the types of power that effective leaders employ

Answered: 1 week ago

Question

Describe how leadership styles should be adapted to the situation

Answered: 1 week ago