You have been given the following specifications of a simple database for keeping track of venues and events at the Olympics (note that primary keys are shown underlined, foreign keys in bold).
You should run your SQL to demonstrate that it works correctly.
VENUE (VenueName, Location, Capacity)
EVENT (EventName, ScheduledStart, VenueName)
Based on the table specifications provided, answer the following questions. Each question is worth 3 marks.
Here are the SQL statements to address each of your questions based on the specifications provided:
CREATE TABLE VENUE (
VenueName VARCHAR2(100) CONSTRAINT VenuePK PRIMARY KEY,
Location VARCHAR2(255) NOT NULL,
Capacity NUMBER(10) NOT NULL
);
CREATE TABLE EVENT (
EventName VARCHAR2(100) NOT NULL,
ScheduledStart TIMESTAMP NOT NULL,
VenueName VARCHAR2(100) NOT NULL,
CONSTRAINT EventPK PRIMARY KEY (EventName),
CONSTRAINT FK_Venue FOREIGN KEY (VenueName) REFERENCES VENUE(VenueName) ON DELETE RESTRICT
);
(Note: The ON DELETE RESTRICT
clause is used here to prevent deletion of a venue if there are events associated with it, as per your requirement.)
INSERT INTO VENUE (VenueName, Location, Capacity)
VALUES ('Maracana Stadium', 'Avenida Maracana', 78838);
ALTER TABLE EVENT
ADD Sport VARCHAR2(50) NOT NULL;
UPDATE VENUE
SET Capacity = 80000
WHERE VenueName = 'Maracana Stadium';
These SQL statements will create the necessary tables, insert data, modify the structure of the EVENT table, and update the capacity of the Maracana Stadium as specified.