You will extend the movie database example to contain information about the stores in a video rental chain, the copies those stores own of movies, and the rentals of those copies to customers. You will model this extension using an E-R diagram and then create the relevant SQL tables and constraints. Your ultimate goal is to be able to answer queries like "What videos featuring Claude Rains does the St. Peter store have copies of in stock?"
Although E-R modeling normally precedes the design of specific SQL tables, when you are extending an existing system, the E-R model may not be available to you. Therefore, you may first reverse engineer the existing system before you plan your changes. The movie system is an example of this situation. Starting from the example on the course web site, draw an E-R diagram. To gain comfort with using MySQL, you may also want to play around with the existing system, for example by replicating the example.
Your new system should satisfy the following requirements:
As the next section explains, the combination of a date and time can be stored in SQL as a single item; your E-R diagram should follow that convention as well.
Draw a revised E-R diagram that reflects the above requirements. You should give some thought to how the past and present rentals will be represented. Choose one of the following three possibilities, and briefly justify why you chose it rather than either of the other two:
NULL
return time.NULL
NULL
return times) are also stored separately, as in the second
option. Presumably this redundant storage of the the present rentals
in two different forms is intended to provide some benefit of
convenience or efficiency.One factor you should consider is that we haven't yet learned enough of the SQL language to be able to answer the goal query (movies in stock containing an actor) with the first option. Even if that is a decisive factor for you, please indicate what other factors you consider, and how your choice might be different if you knew enough SQL to make all three options viable.
Your E-R diagram should be as specific as possible. If there are important constraints that you cannot indicate using the E-R notation, add them as textual notes.
Write a collection of CREATE TABLE
statements based on
your revised E-R model. Include as many of the constraints as you
can. (You can include any CHECK
constraints, they simply
won't be enforced by MySQL.) Demonstrate your database's operation by
putting some data in the tables, then showing the SELECT
query needed to find all movies containing Claude Rains for which
St. Peter has at least one copy that isn't currently rented.
You can use the type DATETIME
to represent a
combination of date and time. When inserting data into tables, you
can enter each DATETIME
as a string; for example, 4:30 pm
on Valentine's day this year is '2005-02-14 16:30:00'
.
The current date and time is available as NOW()
.
Any database that retains personally identifiable information should have an appropriate privacy policy, including in particular a policy regarding how long data is retained. Do you have any thoughts on what a reasonable policy might be in this application domain? Are rental records kept forever, or is there some point at which they should be deleted?
Write a report that is concise and assumes an audience familiar with your assignment and the technology, but which addresses all the above topics in an organized fashion.