Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
481 views

Homework Assignment #3

TinyVideo is a small movie rental company with a single store. TinyVideo needs a database system to track the rental of movies to its members. TinyVideo can own several copies (VIDEO) of each movie (MOVIE). For example, the store may have 10 copies of the movie “Twist in the Wind”. “Twist in the Wind” would be one MOVIE and each copy would be a VIDEO. A rental transaction (RENTAL) involves one or more videos being rented to a member (MEMBERSHIP). A video can be rented many times over its lifetime, therefore, there is a M:N relationship between RENTAL and VIDEO. DETAILRENTAL is the bridge table to resolve this relationship. The complete ERD is provided in Figure P7.65.

Uploaded by

Erik Vigorito
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
481 views

Homework Assignment #3

TinyVideo is a small movie rental company with a single store. TinyVideo needs a database system to track the rental of movies to its members. TinyVideo can own several copies (VIDEO) of each movie (MOVIE). For example, the store may have 10 copies of the movie “Twist in the Wind”. “Twist in the Wind” would be one MOVIE and each copy would be a VIDEO. A rental transaction (RENTAL) involves one or more videos being rented to a member (MEMBERSHIP). A video can be rented many times over its lifetime, therefore, there is a M:N relationship between RENTAL and VIDEO. DETAILRENTAL is the bridge table to resolve this relationship. The complete ERD is provided in Figure P7.65.

Uploaded by

Erik Vigorito
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

COMMIT UPDATE movie SET Movie_Year = 2008 WHERE Movie_Num = 1245 UPDATE movie SET Price_Code = 3 WHERE Movie_Genre

= 'ACTION' UPDATE price SET Price_Rentfee = Price_Rentfee + .50 COMMIT SELECT Movie_Title, Movie_Year, Movie_Genre FROM Movie SELECT movie_year, movie_title, movie_cost from MOVIE ORDER BY MOVIE_YEAR desc SELECT Movie_Title, Movie_Year, Movie_Genre FROM movie ORDER BY Movie_Genre asc, Movie_Year desc SELECT Movie_Num, Movie_Title, Price_Code FROM movie WHERE Movie_Title LIKE 'R%' SELECT Movie_Title, Movie_Year, Movie_Cost FROM movie WHERE Movie_Title like '%hope%' ORDER BY Movie_Title asc SELECT Movie_Title, Movie_Year, Movie_Genre FROM movie where Movie_Genre = 'Action' SELECT movie_num, movie_title, movie_cost from MOVIE WHERE MOVIE_COST > 40 SELECT movie_num movie_title movie_cost FROM MOVIE WHERE ( MOVIE_GENRE = 'Action' or MOVIE_GENRE = 'Comedy' ) and MOVIE_COST < 50 SELECT movie_num movie_title + ' (' + cast(movie_year as varchar(4)) + ') ' + movie_genre as movie_description FROM MOVIE SELECT movie_genre, COUNT(movie_num)as 'Number of Movies' from MOVIE GROUP BY movie_genre SELECT AVG(movie_cost) as 'Average Movie Cost' from MOVIE SELECT movie_genre, AVG(movie_cost) as 'Average Movie Cost' from MOVIE GROUP BY movie_genre SELECT m.movie_title m.movie_genre p.price_description p.price_rentfee FROM MOVIE m inner join PRICE p on m.PRICE_CODE = p.PRICE_CODE SELECT m.movie_genre AVG(p.price_rentfee) as 'Average Rental Fee' FROM MOVIE m inner join PRICE p on m.PRICE_CODE = p.PRICE_CODE GROUP BY m.MOVIE_GENRE SELECT m.movie_title m.movie_year

m.movie_cost/p.price_rentfee as 'Breakeven Rentals' FROM MOVIE m inner join PRICE p on m.PRICE_CODE = p.PRICE_CODE SELECT movie_title, movie_year FROM MOVIE where PRICE_CODE is not NULL SELECT movie_title, movie_year, movie_cost FROM MOVIE where MOVIE_COST BETWEEN 44.00 and 49.99 SELECT m.movie_title m.movie_year p.price_description p.price_rentfee FROM MOVIE m inner join PRICE p on m.PRICE_CODE = p.PRICE_CODE WHERE m.movie_genre IN ('Family', 'Comedy', 'Drama') SELECT movie_num movie_title movie_year FROM MOVIE WHERE movie_num NOT IN (SELECT movie_num FROM VIDEO) SELECT mem_num mem_fname mem_lname mem_balance FROM MEMBERSHIP WHERE mem_num IN (SELECT mem_num FROM RENTAL)

SELECT MIN(mem_balance) as 'Minimum Balance' MAX(mem_balance) as 'Maximum Balance' AVG(mem_balance) as 'Average Balance' FROM MEMBERSHIP WHERE mem_num IN (SELECT mem_num FROM RENTAL) SELECT mem_fname + ' ' + mem_lname as 'Membership Name' mem_street + ' ' + mem_city + ' ' + mem_state + ' ' + cast(mem_zip as varchar(5)) as 'Membership Address' FROM MEMBERSHIP SELECT r.rent_num r.rent_date d.vid_num m.movie_title d.detail_duedate d.detail_returndate FROM RENTAL r inner join DETAILRENTAL d on r.RENT_NUM = d.RENT_NUM inner join VIDEO v on d.VID_NUM = v.VID_NUM inner join MOVIE m on v.MOVIE_NUM = m.MOVIE_NUM WHERE d.DETAIL_RETURNDATE > d.DETAIL_DUEDATE

You might also like