Write a script one step at a time to generate the DB schema of the movie rental database. Test the partial
results by inspecting the tables in SQLDeveloper. Do not go on to the next step until you have the previous step
1. Define the MOVIE rental database
Use the following database schema to create a script that generates and populates the movie rental database. LOOK AT THE SCREENSHOT.
The movie ids should be a 16-char string with the format
Characters 1-3: represent the country of the producer: e.g., USA
Characters 5-8: represent the year of the movie: e.g., 2003
Characters 10-11: represent an identifier of the movie genre: e.g., HR for Horror
Characters 13-16, 4-digit sequence (when characters from 1-12 are the same as a previous entry, the
sequence increments by one). For example, if USA-2003-HR-0001 is already in the table as a
movie id, the next movie to be input with the country: USA, year: 2003, and genre: HR should have
the code USA-2003-HR-0002.
– Customer and director ids are represented by a 9-digit code. Please choose a proper max length for first
names, last names, and movie titles. Check this movie title as a reference to pick your max length.
– dob represents the date of birth of the customer or director, rented indicates the date a movie was
rented and duedate indicates when the movie should be returned.
– duration is a fixed 5-character string with the format HH:MM, e.g. 02:32, 04:43.
– Any date field in the schema should be stored as a date object, not just as character strings. The genre id
and year (4-digit integer) must be consistent with the definition of the movie id explained above.
Define the primary keys and foreign keys as indicated in the schema above. To help you with that, you could:
a. List the attribute(s) that make up the primary key (if one exists) for each of the relations.
b. List the attribute(s) that make up the foreign key(s) (if any exist) in each of the relations.
Hint: you will have to create DIRECTOR before MOVIE, and MOVIE and CUSTOMER before RENTAL.
Include the following constraints:
– Emails should include the @ character (only the @ should be check in the constraint)
– Not two emails can be equal in the same relation
– The movie place only uses movies released from 1950 and later
– Num_rentals, times a movie has been rented, does not allow null values, the DEFAULT value when
populating should be 0.
To avoid name conflicts during repeated runs, start your script file with DROP TABLE commands for all four
tables (for preventing foreign key violation errors put them in reverse order of the creation of the tables).
Run your script and look at the columns and constraints of each table to verify that they have been created
correctly before continuing your work.
2. Populate the database
– Populate the tables in the proper order to avoid referential errors
1) populate the customer and director tables with at least three entries each (make up the data
2) populate the movie table with at least 4 movies (make up the data, values should meet all
corresponding constraints. Pay attention to the director ids)
3) populate the RENTAL table for at least five movie rentals (make up the data values, the values
should meet all corresponding constraints.)
every movie should’ve been rented at least once.
Every director should be used at least once.
Every customer should have rented at least one movie. Some should have rented at
least two. At least one customer should have a rental yet to be returned.
4) Check your data and verify that all the conditions above have been met.
5) Assume that the movie rental place only has one copy of each movie, so the dates for two
rentals of the same movie should NOT overlap. Do not create constraints for this, just make sure
your data meet this criterion.
3. Displaying the content of your tables
– Display ALL the content of each table by adding SELECT statements at the very end of your script,
followed by a single COMMIT; statement.
– Run the complete script and save the complete contents of the script output window, including the
displayed tables, to a text file. (Clear the script output window first so that only the output of the last
run of your script is displayed and saved.)
Why Choose Us
- 100% non-plagiarized Papers
- 24/7 /365 Service Available
- Affordable Prices
- Any Paper, Urgency, and Subject
- Will complete your papers in 6 hours
- On-time Delivery
- Money-back and Privacy guarantees
- Unlimited Amendments upon request
- Satisfaction guarantee
How it Works
- Click on the “Place Your Order” tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
- Fill in your paper’s requirements in the "PAPER DETAILS" section.
- Fill in your paper’s academic level, deadline, and the required number of pages from the drop-down menus.
- Click “CREATE ACCOUNT & SIGN IN” to enter your registration details and get an account with us for record-keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
- From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.