Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume each of your 5 customers rents 2 movies each. Create 5 different transactions that will record each customer renting 2 different movies. Use commit

Assume each of your 5 customers rents 2 movies each. Create 5 different transactions that will record each customer renting 2 different movies. Use commit on all instances. Do use Rollback on one of the transactions and see what happens.

Okay, so these are my tables:

CREATE TABLE customer ( cust_id INT (6) UNSIGNED NOT NULL AUTO_INCREMENT, first_name VARCHAR(20) NOT NULL, last_name VARCHAR(20) NOT NULL, address_1 VARCHAR(20) NOT NULL, address_2 VARCHAR(20) NOT NULL, cc_number INT(16) NOT NULL, cc_expdate DATE NOT NULL, member_since DATE NOT NULL, member_exp DATE NOT NULL, PRIMARY KEY (cust_id) ) ENGINE=InnoDB;

CREATE TABLE movie ( movie_id INT (6) UNSIGNED NOT NULL, title varchar (20) NOT NULL, release_date DATE NOT NULL, rating varchar (20) NOT NULL, qty Int (6) not null, cust_id INT (6) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (movie_id), FOREIGN KEY (cust_id) REFERENCES Customer (cust_id) ) ENGINE=InnoDB;

CREATE TABLE transaction ( trans_ID INT (6) UNSIGNED NOT NULL AUTO_INCREMENT, rental_date DATE NOT NULL, return_date DATE NOT NULL, rental_fee INT NOT NULL, cust_id INT (6) UNSIGNED NOT NULL, movie_id INT (6) UNSIGNED NOT NULL, PRIMARY KEY (trans_ID), FOREIGN KEY (cust_id) REFERENCES Customer (cust_id), FOREIGN KEY (movie_id) REFERENCES movie (movie_id) ) ENGINE=InnoDB;

and these are my values:

'CUSTOMER' VALUES INSERT INTO `Customer` VALUES ('145888','David','Holder','435 Main Street','Houston, TX 77236','8325','2018-02-09','1995-10-09','2018-06-05'); INSERT INTO `Customer` VALUES ('236459','Morgan','Freeman','4887 Old Town Road','Nashoba, OK 45484','1258','1998-12-30','2017-06-07','2019-08-19'); INSERT INTO `Customer` VALUES ('578984','Sheryl','Moore','7654 Pine St.','Spring, TX 45678','6958','2020-03-28','2015-12-18','2030-09-14'); INSERT INTO `Customer` VALUES ('458796','Tiffany','Temple','786 Oak Rd.','Humble, TX 45785','9545','2016-04-24','2013-06-19','2021-04-15'); INSERT INTO `Customer` VALUES ('963584','Adrian','Garza','238 Maple Ct.','Dallas, TX 45818','8745','2019-05-08','1945-05-10','2019-07-04');

'MOVIE' VALUES INSERT INTO `movie` VALUES ('000001','Friday the 13th','1980-05-09','R','10','145888'); INSERT INTO `movie` VALUES ('000002','Urban Cowboy','1980-06-06','R','9','236459'); INSERT INTO `movie` VALUES ('000003','Airplane!','1980-07-04','R','11','578984'); INSERT INTO `movie` VALUES ('000004','Caddyshack','1980-07-25','R','8','458796'); INSERT INTO `movie` VALUES ('000005','Prom Night','1980-08-15','R','13','963584');

How do I go about creating transactions? What's the code that would match my values? It doesn't matter who rents what, just that they rent 2. Also, should the transaction table have "cust_ID" and "movie_ID" as foreign keys (as I have them) or are they supposed to be primary keys - the instructions don't say to add a "transaction_ID"? This is all new to me!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

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

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions