Question: write in sql thx. Table for 11 ,12 CREATE TABLE IF NOT EXISTS football_games ( visitor_name VARCHAR(30), /* Name of the visiting team */ home_score

write in sql thx.
Table for 11 ,12
CREATE TABLE IF NOT EXISTS football_games ( visitor_name VARCHAR(30), /* Name of the visiting team */ home_score SMALLINT NOT NULL, /* Final score of the game for the Buffs */ visitor_score SMALLINT NOT NULL,/* Final score of the game for the visiting team */ game_date DATE NOT NULL, /* Date of the game */ players INT[] NOT NULL, /* This array consists of the football player ids (basically a foreign key to the football_player.id) */ PRIMARY KEY(visitor_name, game_date) /* A game's unique primary key consists of the visitor_name & the game date (this assumes you can't have multiple games against the same team in a single day) */ );
CREATE TABLE IF NOT EXISTS football_players( id SERIAL PRIMARY KEY, /* Unique identifier for each player (it's possible multiple players have the same name/similiar information) */ name VARCHAR(50) NOT NULL, /* The player's first & last name */ year VARCHAR(3), /* FSH - Freshman, SPH - Sophomore, JNR - Junior, SNR - Senior */ major VARCHAR(4), /* The unique 4 character code used by CU Boulder to identify student majors (ex. CSCI, ATLS) */ passing_yards SMALLINT, /* The number of passing yards in the players entire football career */ rushing_yards SMALLINT, /* The number of rushing yards in the players entire football career */ receiving_yards SMALLINT, /* The number of receiving yards in the players entire football career*/ img_src VARCHAR(200) /* This is a file path (absolute or relative), that locates the player's profile image */ );
INSERT INTO football_games(visitor_name, home_score, visitor_score, game_date, players) VALUES('Colorado State', 45, 13, '20180831', ARRAY [1,2,3,4,5]), ('Nebraska', 33, 28, '20180908', ARRAY [2,3,4,5,6]), ('New Hampshire', 45, 14, '20180915', ARRAY [3,4,5,6,7]), ('UCLA', 38, 16, '20180928', ARRAY [4,5,6,7,8]), ('Arizona State', 28, 21, '20181006', ARRAY [5,6,7,8,9]), ('Southern California', 20, 31, '20181013', ARRAY [6,7,8,9,10]), ('Washington', 13, 27, '20181020', ARRAY [7,8,9,10,1]), ('Oregon State', 34, 41, '20181027', ARRAY [8,9,10,1,2]), ('Arizona', 34, 42, '20181102', ARRAY [9,10,1,2,3]), ('Washington State', 7, 31, '20181110', ARRAY [10,1,2,3,4]), ('Utah', 7, 30, '20181117', ARRAY [1,2,3,4,5]), ('California', 21, 33, '20181124', ARRAY [2,3,4,5,6]) ;
INSERT INTO football_players(name, year, major, passing_yards, rushing_yards, receiving_yards) VALUES('Cedric Vega', 'FSH', 'ARTS', 15, 25, 33), ('Myron Walters', 'SPH', 'CSCI', 32, 43, 52), ('Javier Washington', 'JNR', 'MATH', 1, 61, 45), ('Wade Farmer', 'SNR', 'ARTS', 14, 55, 12), ('Doyle Huff', 'FSH', 'CSCI', 23, 44, 92), ('Melba Pope', 'SPH', 'MATH', 13, 22, 45), ('Erick Graves', 'JNR', 'ARTS', 45, 78, 98 ), ('Charles Porter', 'SNR', 'CSCI', 92, 102, 125), ('Rafael Boreous', 'JNR', 'MATH', 102, 111, 105), ('Jared Castillo', 'SNR', 'ARTS', 112, 113, 114);
For 10 you are required to create two views
as below:
8.Write a script to create a view that counts the total number of winning games.
9.Write a script to create a view that counts the total number of games played.
AS I said, 8,9 are just ask you to create two views based on the given table.
What I wrote for 8 and 9 is below:
8.CREATE VIEW win_gamea AS SELECT count(*) AS "Totala" from football_games where home_score > visitor_score; 9.CREATE VIEW all_gamesa AS SELECT count(visitor_name) AS "Total2" from football_games;
10. Write a script that uses the two views you created (from 8 & 9) to calculate the percent of wins. 11. Write a script that will count how many games Don't worry about handling multiple Cedric Vegas, you can assume "Cedric Vega" has played in during his entire here is only 1 football player named Cedric Vega. This should to football career. simplify your query 12. Write a script that will calculate the average number Don't worry about handling multiple Cedric Vegas, you can of rushing yards for "Cedric Vega", based on the number assume there is only 1 football player named Cedric Vega. This of games he has played should to simplify your query 10. Write a script that uses the two views you created (from 8 & 9) to calculate the percent of wins. 11. Write a script that will count how many games Don't worry about handling multiple Cedric Vegas, you can assume "Cedric Vega" has played in during his entire here is only 1 football player named Cedric Vega. This should to football career. simplify your query 12. Write a script that will calculate the average number Don't worry about handling multiple Cedric Vegas, you can of rushing yards for "Cedric Vega", based on the number assume there is only 1 football player named Cedric Vega. This of games he has played should to simplify your query
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
