Question
WRITING POSTGRESQL QUERIES RELATIONS: CREATE TABLE Movies( movieID INT, year INT UNIQUE, rating CHAR(1), length INT, totalEarned NUMERIC(7,2), PRIMARY KEY(movieID) ); CREATE TABLE Theaters( theaterID
WRITING POSTGRESQL QUERIES
RELATIONS:
CREATE TABLE Movies( movieID INT, year INT UNIQUE, rating CHAR(1), length INT, totalEarned NUMERIC(7,2), PRIMARY KEY(movieID) );
CREATE TABLE Theaters( theaterID INT, address VARCHAR(40) UNIQUE, numSeats INT NOT NULL, PRIMARY KEY(theaterID) );
CREATE TABLE TheaterSeats( theaterID INT, seatNum INT, brokenSeat BOOLEAN NOT NULL, PRIMARY KEY(theaterID, seatNum), FOREIGN KEY(theaterID) REFERENCES Theaters );
CREATE TABLE Showings( theaterID INT, showingDate DATE, startTime TIME, movieID INT, priceCode CHAR(1), PRIMARY KEY(theaterID, showingDate, startTime), FOREIGN KEY(theaterID) REFERENCES Theaters, FOREIGN KEY(movieID) REFERENCES Movies );
CREATE TABLE Customers( customerID INT, name VARCHAR(30) UNIQUE, address VARCHAR(40) UNIQUE, joinDate DATE, status CHAR(1), PRIMARY KEY(customerID) );
CREATE TABLE Tickets( theaterID INT, seatNum INT, showingDate DATE, startTime TIME, customerID INT, ticketPrice NUMERIC(4,2), PRIMARY KEY(theaterID, seatNum, showingDate, startTime), FOREIGN KEY(customerID) REFERENCES Customers, FOREIGN KEY(theaterID, seatNum) REFERENCES TheaterSeats, FOREIGN KEY(theaterID, showingDate, startTime) REFERENCES Showings );
QUERY TO WRITE: Find the customerID and name of each customer whose name has the letter a or A anywhere in it, and who bought tickets to at least 2 different movies. Careful; a customer who bought 2 or more tickets to the same movie doesn't qualify. No duplicates should appear in your answer
Step by Step Solution
There are 3 Steps involved in it
Step: 1
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-text-image.webp)
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Step: 3
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started