0% found this document useful (0 votes)
9 views

Adv Database

Uploaded by

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

Adv Database

Uploaded by

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

CREATE TABLE Customers2 (

CustomerID INT PRIMARY KEY,


CustomerName VARCHAR(255) NOT NULL,
Address VARCHAR(255),
ContactInfo VARCHAR(255)
);
-- Create Organizer table
CREATE TABLE Organizer (
OrganizerID INT PRIMARY KEY,
OrganizerName VARCHAR(255) NOT NULL,
ContactInfo VARCHAR(255)
);

-- Create Venue table


CREATE TABLE Venue (
VenueID INT PRIMARY KEY,
VenueName VARCHAR(255) NOT NULL,
Capacity INT,
Location VARCHAR(255),
Price DECIMAL(10, 2)
);

-- Create Event table


CREATE TABLE Event (
EventID INT PRIMARY KEY,
EventType VARCHAR(255),
EventDate DATE,
VenueID INT,
OrganizerID INT,
Budget DECIMAL(10, 2),
Description TEXT,
FOREIGN KEY (VenueID) REFERENCES Venue(VenueID),
FOREIGN KEY (OrganizerID) REFERENCES Organizer(OrganizerID)
);

CREATE TABLE Bookings (


BookingID INT PRIMARY KEY,
EventID INT,
CustomerName VARCHAR(100),
BookingDate DATE,
FOREIGN KEY (EventID) REFERENCES Event(EventID)
);

############################################################

-- Insert sample data into the Customers table (formerly Hotels)


INSERT INTO Customers2 (CustomerID, CustomerName, Address, ContactInfo)
VALUES
(1, 'Customer 1', '123 Main Street, City, Country', '[email protected]'),
(2, 'Customer 2', '456 Elm Avenue, Town, Country', '[email protected]');
-- Insert more sample data into the Customers table
INSERT INTO Customers2 (CustomerID, CustomerName, Address, ContactInfo)
VALUES
(3, 'Customer 3', '789 Beach Road, Seaside City, Country', '[email protected]'),
(4, 'Customer 4', 'Mountain Retreat, Pine Forest, Country', '[email protected]');
-- Insert sample data into the Organizer table
INSERT INTO Organizer (OrganizerID, OrganizerName, ContactInfo)
VALUES
(1, 'ABC Events', '[email protected]'),
(2, 'XYZ Weddings', '[email protected]');

-- Insert sample data into the Venue table


INSERT INTO Venue (VenueID, VenueName, Capacity, Location, Price)
VALUES
(1, 'Grand Ballroom', 500, 'First Floor', 2000.00),
(2, 'Conference Room A', 100, 'Second Floor', 500.00);

-- Insert sample data into the Event table


INSERT INTO Event (EventID, EventType, EventDate, VenueID, OrganizerID, Budget, Description)
VALUES
(1, 'Wedding', '2023-05-20', 1, 1, 10000.00, 'Sample wedding event description'),
(2, 'Conference', '2023-08-10', 2, 2, 5000.00, 'Sample conference event description');

-- Insert more sample data into the Organizer table


INSERT INTO Organizer (OrganizerID, OrganizerName, ContactInfo)
VALUES
(3, 'Event Producers Inc.', '[email protected]'),
(4, 'Seminars R Us', '[email protected]');

-- Insert more sample data into the Venue table


INSERT INTO Venue (VenueID, VenueName, Capacity, Location, Price)
VALUES
(3, 'Garden Pavilion', 200, 'Garden Area', 1500.00),
(4, 'Boardroom B', 50, 'Third Floor', 800.00);

-- Insert more sample data into the Event table


INSERT INTO Event (EventID, EventType, EventDate, VenueID, OrganizerID, Budget, Description)
VALUES
(3, 'Corporate Retreat', '2023-06-15', 3, 3, 8000.00, 'Sample corporate retreat event description'),
(4, 'Seminar on Technology', '2023-09-05', 4, 4, 3000.00, 'Sample technology seminar description');
##############################################################
select * from Event ;
-- Selecting data from the Event table along with related information from other tables
SELECT
Event.EventID,
Event.EventType,
Event.EventDate,
Venue.VenueName,
Venue.Capacity,
Venue.Location AS VenueLocation,
Venue.Price AS VenuePrice,
Organizer.OrganizerName,
Customers2.CustomerName AS CustomerName,
Bookings.BookingDate
FROM
Event
JOIN Venue ON Event.VenueID = Venue.VenueID
JOIN Organizer ON Event.OrganizerID = Organizer.OrganizerID
JOIN Bookings ON Event.EventID = Bookings.EventID
JOIN Customers2 ON Bookings.CustomerName = Customers2.CustomerName;

You might also like