0% found this document useful (0 votes)
5 views5 pages

SQL Queries

The document contains SQL queries for creating tables related to an event management system, including tables for Organizer, User, Venue, Event, and Registration. It also includes insert, update, delete, and general queries for managing and retrieving data from these tables, such as counting events by organizer and checking for events exceeding venue capacity. The queries are structured to facilitate data manipulation and retrieval for various event-related operations.

Uploaded by

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

SQL Queries

The document contains SQL queries for creating tables related to an event management system, including tables for Organizer, User, Venue, Event, and Registration. It also includes insert, update, delete, and general queries for managing and retrieving data from these tables, such as counting events by organizer and checking for events exceeding venue capacity. The queries are structured to facilitate data manipulation and retrieval for various event-related operations.

Uploaded by

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

Queries related to Create:

Query 1:

CREATE TABLE Organizer (

OrganizerID INT PRIMARY KEY,

FullName VARCHAR(100),

Email VARCHAR(100),

ContactNumber VARCHAR(15)

);

Query 2:

CREATE TABLE User (

UserID INT PRIMARY KEY,

Name VARCHAR(100),

Email VARCHAR(100),

Phone VARCHAR(15)

);

Query 3:

CREATE TABLE Venue (

VenueID INT PRIMARY KEY,

VenueName VARCHAR(100),

Location VARCHAR(100),

Capacity INT

);

Query 4:
CREATE TABLE Event (

EventID INT PRIMARY KEY,

EventName VARCHAR(100),

EventType VARCHAR(50),

Date DATE,

Time TIME,

VenueID INT,

OrganizerID INT,

FOREIGN KEY (VenueID) REFERENCES Venue(VenueID),

FOREIGN KEY (OrganizerID) REFERENCES Organizer(OrganizerID)

);

Query 5:

CREATE TABLE Registration (

TicketID VARCHAR(20) PRIMARY KEY,

EventID INT,

UserID INT,

SeatNumber VARCHAR(10),

FOREIGN KEY (EventID) REFERENCES Event(EventID),

FOREIGN KEY (UserID) REFERENCES User(UserID)

);

Insert Queries:
Insert all the data given in excel sheet using queires into the tables created
using the above queries.

Insert query:

INSERT INTO Venue (VenueID, VenueName, Location, Capacity)

VALUES (10,'Venue 10, 'Claytonton', 437),

VALUES(3,’Venue 3’, ‘North Leeport’, 662),

And so on..

Create in a similar way for all other tables as per the data given in exce
sheet.

Update Queries:

UPDATE Organizer

SET ContactNumber = '9998887776'

WHERE OrganizerID = 5;

Delete Queries:

DELETE FROM User

WHERE UserID = 30;

General Queries:

Get all Events with Venue and Organizer Names:


SELECT e.EventName, e.Date, e.Time, v.VenueName, o.FullName AS
Organizer

FROM Event e

JOIN Venue v ON e.VenueID = v.VenueID

JOIN Organizer o ON e.OrganizerID = o.OrganizerID;

Upcoming Events after a Specific Date:

SELECT EventName, Date

FROM Event

WHERE Date > '2025-08-19'

ORDER BY Date ASC;

View All Registrations for a Specific Event:

SELECT r.TicketID, u.Name AS UserName, r.SeatNumber

FROM Registration r

JOIN User u ON r.UserID = u.UserID

WHERE r.EventID = 5;

Count of Events Organized by Each Organizer:

SELECT o.FullName, COUNT(e.EventID) AS TotalEvents

FROM Organizer o

JOIN Event e ON o.OrganizerID = e.OrganizerID

GROUP BY o.OrganizerID;

Total Tickets Sold per Event:

SELECT e.EventName, COUNT(r.TicketID) AS TicketsSold


FROM Event e

LEFT JOIN Registration r ON e.EventID = r.EventID

GROUP BY e.EventID;

Users Registered for More Than 1 Event:

Select count(r.eventID) as eventsregistered, u.userid, u.Name

From user u

Join registration r on u.userid = r.userid

Group by u.userid

Having count(r.eventID) > 1;

Events Exceeding Venue Capacity:

SELECT e.EventName, COUNT(r.TicketID) AS Bookings, v.Capacity

FROM Event e

JOIN Registration r ON e.EventID = r.EventID

JOIN Venue v ON e.VenueID = v.VenueID

GROUP BY e.EventID

HAVING COUNT(r.TicketID) > v.Capacity;

You might also like