0% found this document useful (0 votes)
18 views3 pages

SQL Movie Database Creation and Queries

The document creates tables to store movie and box office data. The Movies table stores information about movies like title, director, year, and length. The Boxoffice table stores box office data like ratings and domestic/international sales amounts. Records are inserted into both tables for 14 Disney/Pixar movies. Queries are written to find domestic/international sales by movie, movies where international sales exceeded domestic sales, and movies ordered by rating.

Uploaded by

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

SQL Movie Database Creation and Queries

The document creates tables to store movie and box office data. The Movies table stores information about movies like title, director, year, and length. The Boxoffice table stores box office data like ratings and domestic/international sales amounts. Records are inserted into both tables for 14 Disney/Pixar movies. Queries are written to find domestic/international sales by movie, movies where international sales exceeded domestic sales, and movies ordered by rating.

Uploaded by

santhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

a) Create the "Movies" table:

CREATE TABLE Movies (


Id INT PRIMARY KEY,
Title VARCHAR2(50),
Director VARCHAR2(50),
Year VARCHAR2(4),
"Length mins" INT
);

b) Describe the table "Movies":

DESC Movies;

c) Insert records into "Movies" table:

INSERT ALL
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (1, 'Toy Story', 'John
Lasseter', '1995', 81)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (2, 'A Bug''s Life', 'John
Lasseter', '1998', 95)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (3, 'Toy Story 2', 'John
Lasseter', '1999', 93)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (4, 'Monsters, Inc.', 'Pete
Docter', '2001', 92)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (5, 'Finding Nemo', 'Andrew
Stanton', '2003', 107)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (6, 'The Incredibles', 'Brad
Bird', '2004', 116)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (7, 'Cars', 'John Lasseter',
'2006', 117)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (8, 'Ratatouille', 'Brad Bird',
'2007', 115)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (9, 'WALL-E', 'Andrew
Stanton', '2008', 104)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (10, 'Up', 'Pete Docter',
'2009', 101)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (11, 'Toy Story 3', 'Lee
Unkrich', '2010', 103)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (12, 'Cars 2', 'John
Lasseter', '2011', 120)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (13, 'Brave', 'Brenda
Chapman', '2012', 102)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (14, 'Monsters University',
'Dan Scanlon', '2013', 110)
SELECT * FROM dual;

d) Create the "Boxoffice" table:

CREATE TABLE Boxoffice (


Movie_id INT PRIMARY KEY,
Rating FLOAT,
Domestic_sales INT,
International_sales INT
);

e) Insert records into "Boxoffice" table:

INSERT ALL
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (5, 8.2,
380843261, 555900000)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (14, 7.4,
268492764, 475066843)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (8, 8,
206445654, 417277164)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (12, 6.4,
191452396, 368400000)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (3, 7.9,
245852179, 239163000)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (6, 8,
261441092, 370001000)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (9, 8.5,
223808164, 297503696)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (11, 8.4,
415004880, 648167031)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (1, 8.3,
191796233, 170162503)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (7, 7.2,
244082982, 217900167)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (10, 8.3,
293004164, 438338580)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (4, 8.1,
289916256, 272900000)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (2,

7.2, 162798565, 200600000)


INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (13, 7.2,
237283207, 301700000)
SELECT * FROM dual;
f) Find the domestic and international sales for each movie:

SELECT
[Link],
[Link],
b.Domestic_sales,
b.International_sales
FROM
Movies m
JOIN
Boxoffice b ON [Link] = b.Movie_id;

g) Show the sales numbers for each movie that did better internationally rather than
domestically:

SELECT
[Link],
[Link],
b.Domestic_sales,
b.International_sales
FROM
Movies m
JOIN
Boxoffice b ON [Link] = b.Movie_id
WHERE b.International_sales > b.Domestic_sales;

h) List all the movies by their ratings in descending order:

SELECT
[Link],
[Link],
[Link]
FROM
Movies m
JOIN
Boxoffice b ON [Link] = b.Movie_id
ORDER BY [Link] DESC;

Common questions

Powered by AI

To determine the most commercially successful movie, you would use: SELECT m.Id, m.Title, (b.Domestic_sales + b.International_sales) AS Total_Sales FROM Movies m JOIN Boxoffice b ON m.Id = b.Movie_id ORDER BY Total_Sales DESC LIMIT 1 . This query provides insights into overall market success, signals which types of movies have wide audience appeal, and may influence future production and marketing strategies by identifying characteristics of the highest-grossing film.

The database structure, through its linked "Movies" and "Boxoffice" tables, allows for a straightforward evaluation of financial and critical success by querying ratings, domestic, and international sales for each director's films. Using SQL, one can compare metrics such as average rating and total revenue for John Lasseter's films ('Toy Story', 'A Bug's Life', 'Cars') against Andrew Stanton's ('Finding Nemo', 'WALL-E'). By analyzing these parameters, stakeholders can compare directors' abilities to drive box office performance and critical acclaim .

Listing movies by ratings in descending order aids in recognizing high-quality productions that may serve as benchmarks or sequels. It guides strategic decisions like resource allocation towards high-potential projects and reinforces successful elements. The facilitating SQL query is: SELECT m.Id, m.Title, b.Rating FROM Movies m JOIN Boxoffice b ON m.Id = b.Movie_id ORDER BY b.Rating DESC . Analyzing top-rated movies helps identify features that resonate with audiences and critics, influencing future content directions and marketing approaches.

Insights from comparing domestic and international sales figures include understanding market preferences and regional appeal. Movies performing better internationally suggest wider global acceptance or higher international marketing effort. To identify such movies, the SQL query is: SELECT m.Id, m.Title, b.Domestic_sales, b.International_sales FROM Movies m JOIN Boxoffice b ON m.Id = b.Movie_id WHERE b.International_sales > b.Domestic_sales . This query lists movies with higher international sales, highlighting their global success relative to domestic markets.

The multi-record insert statement in SQL signifies an efficient approach for batch processing during database operations, allowing multiple entries to be added to a table with a single command. This method optimizes data entry by reducing the overhead associated with executing multiple individual insert statements, thereby speeding up the data import process and ensuring consistent data state management . It enhances operational efficiency, especially when inputting large datasets into the system.

The relationship between the "Movies" and "Boxoffice" tables is designed as a one-to-one relationship based on the "Movie_id" column, which serves as the primary key in the "Boxoffice" table and a foreign key reference to the "Id" column in the "Movies" table . This implies that each movie in the "Movies" table has a corresponding entry in the "Boxoffice" table, allowing for individual movie box office performance tracking. This design ensures that each movie's financial performance can be directly associated with its details in the "Movies" table.

If a movie's international sales surpass domestic sales, this suggests strong global market appeal and potential. For commercial strategy, this could imply prioritizing international markets for future releases, focusing marketing efforts on regions showing higher interest, and possibly creating culturally tailored content or local partnerships. Such insights are critical for formulating distribution strategies and maximizing global box office potential . It also indicates differing regional interests, guiding strategic decisions on content and marketing spends.

A production company might focus on the highest-rated movies to leverage them for future projects, marketing strategies, or franchise development, enhancing brand value and audience trust. An SQL query to identify these movies is: SELECT m.Id, m.Title, b.Rating FROM Movies m JOIN Boxoffice b ON m.Id = b.Movie_id ORDER BY b.Rating DESC . This query helps them pinpoint the top performers by rating, enabling strategic planning based on audience and critical acclaim.

Discrepancies in a single director's movie ratings, such as those of John Lasseter, could stem from various factors like changes in narrative style, target demographics, or competition at the time of release. The database aids investigation by allowing a query on movie ratings alongside sales and production years, thus providing a comprehensive view of how these factors might correlate with rating differences. Evaluating trends such as changes over time or comparing peer releases can yield deeper insights into rating variability .

Directors like John Lasseter, Brad Bird, and Pete Docter are significant in the dataset as they repeatedly direct high-grossing and critically acclaimed movies. John Lasseter, for instance, directed 'Toy Story', 'A Bug's Life', and 'Cars', illustrating his influence and success in creating beloved family entertainment . Brad Bird's movies such as 'The Incredibles' and 'Ratatouille' show his narrative strengths in animation, while Pete Docter's 'Monsters, Inc.' and 'Up' reflect his ability to blend emotional depth with commercial success. Their repeated presence underscores their roles in shaping successful cinematic universes.

You might also like