Merge pull request #2 from jpez-development/querying

Queries added and waiting to be tested
This commit is contained in:
Joshua Perry 2022-05-12 18:56:44 +01:00 committed by GitHub
commit c78c153cef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 82 additions and 24 deletions

View File

@ -2,28 +2,28 @@ CREATE TABLE players (
player_id NUMBER(4),
player_name VARCHAR2(15),
contact_email VARCHAR2(25),
contact_number CHAR(13),
)
contact_number CHAR(13)
);
CREATE TABLE teams (
team_id NUMBER(4),
team_name VARCHAR2(15),
date_established DATE,
)
date_established DATE
);
CREATE TABLE team_players (
team_player_id NUMBER(8),
player_id NUMBER(4),
team_id NUMBER(4),
date_joined DATE,
)
date_joined DATE
);
CREATE TABLE categories (
genre_id NUMBER(4),
genre_name VARCHAR2(15),
genre_description VARCHAR2(200),
genre_accronym CHAR(5),
)
genre_accronym CHAR(5)
);
CREATE TABLE tournaments (
tournament_id NUMBER(4),
@ -33,43 +33,43 @@ CREATE TABLE tournaments (
tournament_city VARCHAR2(15),
tournament_country VARCHAR2(15),
tournament_arena VARCHAR2(15),
genre_id NUMBER(4),
)
genre_id NUMBER(4)
);
CREATE TABLE tournament_participants (
tournament_participant_id NUMBER(8),
tournament_id NUMBER(8),
player_id NUMBER(4),
team_id NUMBER(4),
)
team_id NUMBER(4)
);
CREATE TABLE sponsors (
sponsor_id NUMBER(4),
sponsor_name VARCHAR2(15),
sponsor_type VARCHAR2(15),
sponsor_start_date DATE,
sponsor_end_date DATE,
)
sponsor_end_date DATE
);
CREATE TABLE prizes (
prize_id NUMBER(8),
sponsor_id NUMBER(4),
tournament_id NUMBER(4),
prize_amount NUMBER(10),
achievement_name VARCHAR2(15),
)
achievement_name VARCHAR2(15)
);
CREATE TABLE rounds (
round_id NUMBER(8),
round_name VARCHAR2(25),
round_description VARCHAR2(200),
)
round_description VARCHAR2(200)
);
CREATE TABLE games (
game_id NUMBER(8),
game_name VARCHAR2(15),
round_id NUMBER(8),
)
round_id NUMBER(8)
);
CREATE TABLE statistics (
game_result_id NUMBER(8),
@ -78,11 +78,11 @@ CREATE TABLE statistics (
game_WLD CHAR(4),
game_kills NUMBER(5),
game_deaths NUMBER(5),
game_assists NUMBER(5),
)
game_assists NUMBER(5)
);
CREATE TABLE game_participants (
game_participant_id NUMBER(16),
game_id NUMBER(8),
tournament_participant_id NUMBER(8),
)
tournament_participant_id NUMBER(8)
);

View File

@ -0,0 +1,58 @@
--Setup Session
ALTER SESSION
SET NLS_DATE_FORMAT = "DD-MON-YYYY HH24:MI:SS";
SET PAGESIZE ??;
SET LINESIZE ???;
SET WRAP OFF;
--Select all from a table
SELECT * FROM table_name WHERE table_name="&table_name";
--Select three columns from table and return in reverse alphabetical order
SELECT column_one, column_two, column_three FROM table_name
WHERE table_name="&table_name"
AND column_one="&column_one"
AND column_two="&column_two"
AND column_three="&column_three"
ORDER BY column_one DESC;
--Select with predictate for statistics table
SELECT game_id FROM statistics
WHERE game_duration LIKE "&game_duration"
AND game_kills LIKE "&game_kills"
AND game_deaths LIKE "&game_deaths";
--Select with pattern
SELECT player_name FROM players
WHERE player_name LIKE "&player_name%"
AND contact_email IS NOT NULL;
--Select with negative predictate
SELECT prize_amount FROM prizes
WHERE achievement_name NOT="winner"
AND prize_amount > 100;
--2 table join query
SELECT tournament_name, genre_name
FROM categories, tournaments
WHERE categories.genre_id = tournaments.genre_id;
--3 table join query
SELECT team_name, player_name, team_player_id
FROM teams, players, team_players
WHERE teams.team_id = team_players.team_id
AND players.player_id = team_players.player_id;
--Additional query
SELECT tournament_name, genre_name, prize_amount, tournament_start_date
FROM categories, tournaments, prizes
WHERE categories.genre_id = tournaments.genre_id
AND tournaments.tournament_id = prizes.tournament_id
ORDER BY prize_amount DESC;
--Additional query ordered by start date
SELECT tournament_name, genre_name, prize_amount, tournament_start_date
FROM categories, tournaments, prizes
WHERE categories.genre_id = tournaments.genre_id
AND tournaments.tournament_id = prizes.tournament_id
ORDER BY tournament_start_date ASC;

Binary file not shown.