0% found this document useful (0 votes)
4 views2 pages

DB Note Search-View

The document contains SQL queries for retrieving and viewing tournament and organizer data, including filtering by tournament type and duration. It also defines several views for organizing this information, such as details of organizers, tournament information, total tournaments, and average duration by tournament type. These views facilitate easy access to summarized tournament data for analysis.

Uploaded by

Jamilur Reza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

DB Note Search-View

The document contains SQL queries for retrieving and viewing tournament and organizer data, including filtering by tournament type and duration. It also defines several views for organizing this information, such as details of organizers, tournament information, total tournaments, and average duration by tournament type. These views facilitate easy access to summarized tournament data for analysis.

Uploaded by

Jamilur Reza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

----------------------------------------------------------------

searching
---------------------------------------------------------------
Retrieve tournaments by type:
SELECT * FROM TOURNAMENT WHERE TOURNAMENT_TYPE = 'Football';

Retrieve organizers by tournament ID:


SELECT * FROM ORGANIZER WHERE TOURNAMENT_ID = 1;

Retrieve tournament information by type:


SELECT * FROM INFO WHERE TOURNAMENT_TYPE = 'Football';

Retrieve organizers for a specific tournament:


SELECT o.*
FROM ORGANIZER o
JOIN TOURNAMENT t ON o.TOURNAMENT_ID = t.TOURNAMENT_ID
WHERE t.TOURNAMENT_NAME = 'Football League';

Retrieve tournament information with duration greater than a specific value:


SELECT t.*
FROM TOURNAMENT t
JOIN INFO i ON t.TOURNAMENT_ID = i.TOURNAMENT_ID
WHERE i.DURATION > 20;

--------------------------------------------------------------------
view
--------------------------------------------------------------------

2.1. Organizers Details View:

CREATE VIEW organizers_details_view AS


SELECT o.ORGANIZER_ID, o.ORGANIZER_NAME, t.TOURNAMENT_NAME, t.TOURNAMENT_DATE,
t.TOURNAMENT_TYPE
FROM ORGANIZER o
JOIN TOURNAMENT t ON o.TOURNAMENT_ID = t.TOURNAMENT_ID;

SELECT * FROM organizers_details_view;

-------------------------------------------------------------------------

2.2. Tournament Info View:

CREATE VIEW tournament_info_view AS


SELECT t.TOURNAMENT_ID, t.TOURNAMENT_NAME, t.TOURNAMENT_DATE, t.TOURNAMENT_TYPE,
i.TOURNAMENT_TYPE AS INFO_TYPE, i.DURATION
FROM TOURNAMENT t
LEFT JOIN INFO i ON t.TOURNAMENT_ID = i.TOURNAMENT_ID;
SELECT * FROM tournament_info_view;

-----------------------------------------------------------------------------

3.1. Total Tournaments View:

CREATE VIEW total_tournaments_view AS


SELECT COUNT(*) AS total_tournaments FROM TOURNAMENT;

SELECT * FROM total_tournaments_view;

---------------------------------------------------------------------------

3.2. Average Duration by Tournament Type View:

CREATE VIEW avg_duration_by_type_view AS


SELECT t.TOURNAMENT_TYPE, AVG(i.DURATION) AS avg_duration
FROM INFO i
JOIN TOURNAMENT t ON i.TOURNAMENT_ID = t.TOURNAMENT_ID
GROUP BY t.TOURNAMENT_TYPE;

SELECT * FROM avg_duration_by_type_view;

You might also like