Compare typical online activities with the minimum download speed (Megabits per second, or Mbps) needed for adequate performance for each application. Additional speed may enhance performance. Speeds are based on running one activity at a time.
Read this whole document before starting this project. There is a lot ofvaluable information here, including the Final Comments section at the bottom.Congratulations, you are opening your own video rental store!You' signed a contract with a content provider that has videos of all the movies in the IMDB database, and you will resell these videos to your customers.Your store allows customers to search the IMDB movie database, then rent movies (which we assume are delivered by the content provider; we don't do this part in the project).After renting a movie, the customer may watch it as many times as she wants, until she decides to "return" it to your store. You need to keep track of which customers are currently renting what movies.There are two important restrictions: Your contract with the content provider allows you to rent each movie to at most one customer at any time. The movie needs to be first returned before you may rent it again to another customer (or the same customer).
Your own business model imposes a second restriction: your store is based on subscriptions (much like Netflix), allowing customers to rent up to a maximum number of movies, depending on their rental plan. Once they reach that number you will deny them more rentals, until they return a movie. You offer a few different rental plans, each with its own monthly fee and maximum number of movies.
In this homework, you have two main tasks. The first is to design a database of your customers.The second taskis to complete a working prototype of your video store application that connects to the database then allows the customer to use a command-lineinterface to search, rent, and return movies.We have already provided code for a complete UI and partial back end; you will implement the rest of the back end.In real-life, you would develop a Web-based interface instead of a command-line interface, but we use a command-line interface to simplify this homework.Task 0: Running the starter code (0 points) Your system will be a Java application. Download the starter code files; you will see the following files:VideoStore.java: the command-line interface to your video store; calls into Query.java to run customer transactionsQuery.java: code to run customer transactions against your database, such as renting and returning moviesdbconn.properties: a file containing settings to connect to the customer and IMDB databases. You need to edit it before running the starter code.sqljdbc4.jar: the JDBC to SQL Server driver. This tells Java how to connect to a SQL Azure database server, and needs to be in your CLASSPATH (see below)sqljdbc.jar: the JDBC to SQL Server driver for older versions of Java. Use this driver only if the other one does not work for you. To run the starter code, run javac and java from the command line (you can download the Java JDK here if you do not already have it). It should be easy enough to run the project using Eclipse or any other Java IDE (see below for some starting tips), but you are somewhat on your own if you want to do that. Please use the discussion board to trade hints and ideas if you have problems doing that.You also need to access the IMDB database on SQL Azure from Homework 3. Modify dbconn.properties with your username and password for SQL Azure. This allows your java program to connect to the database on SQL Azure. You are now ready to try the starter code. Please follow the instructions for your platform as shown in the table below. The last command launches the starter code. Normally, you run it like this:
Command Performance Full Movie Hd Download
If you got an error message about the JDBC driver when running the above, try to use the older driver sqljdbc.jar instead of sqljdbc4.jar.Now you should see the command-line prompt for your video store: *** Please enter one of the following commands ***> search > plan []> rent > return > fastsearch > quit>The search command works (sort of). Try typing:search NixonAfter a few seconds, you should start getting movie titles containing the word'Nixon', and their directors. (You don't yet get the actors: one ofyour jobs is to list the actors.) An alternative way to run the starter code from Eclipse on Windows (posted by a student on the discussion board): So the instructions seem to emphasize running this application out of a terminal. Since my primary box is Windows, and the terminal is a pain in Windows, I set it up to run entirely in Eclipse so I didn't have to deal with it. Here are the steps you need to do:
When your application starts, it reads a customer username and passwordfrom the command line. It validates them against the database, thenretains the customer id throughout the session. All actions (rentals/returns etc) areon behalf of this single customer: to change the customer you mustquit the application and restart it with another customer. The authentication logic is not yet wired up in the starter code;as mentioned above, one of your tasks will be to make it work.Once the application is started, the customer can select one of thefollowing commands:Search for movies by words or strings in the title name.View a list of rental subscription plans, and change his/her plan.Rent a movie by IMDB ID number.Return a rented movie, again by IMDB ID number.To complete your application, you will do the following:Complete the provided IMDB movie search function, fixing a security flaw in it along the way.Write a new, faster version of the search function.Implement the remaining functions in Query.java to read and write customer data from your database, taking care to ensure atomic transaction semantics.Task 2A: Completing the search function (20 points)In the search command, the user types in a string, and you return: all movies whose title matches the string, case-insensitively their director(s) their actor(s) an indication of whether the movie is available for rental (remember that you can rent the movie to only one customer at a time), or whether the movie is already rented by this customer (some customers forget; be nice to them), or whether it is unavailable (rented by someone else).The starter code already returns the movies and directors.Your task is to return all actors, and also to indicate whether the movie is available for rental.Task 2B: Push the join to the database engine (20 points)Goal: When writing programs that talk to a back-end DBMS it is possible to implement some of the data processing either in the Java code or in the SQL statements. In the first case we issue many SQL queries and perform some of the query processing in Java; in the latter case we issue only one (or a small number) of SQL queries and push most of the work to the database engine. We used the former in Task 2A; we will use the latter in 2B. In this task you will reimplement the search function from 2A but instead of dependent joins you will push the joins to the database engine. In principle, this should be faster, however, you may not necessarily notice that: on our small database the speed is affected much more dramatically by whether you are running with a cold cache, or a hot cache, and by the network traffic. Write a function called fastsearch, by using joins (or outer joins? you need to determine that!) computed in the database engine, instead of the dependent joins computed in Java by the search function. Your fastsearch should return only (1) the movie information (id, title, year), (2) its actors, and (3) its director. It does not need to return the rental status. Notice that search issues O(n) SQL queries, because for each movie it runs a separate SQL query to find all its directors (and its actors). Instead, you will write fastsearch to issue only O(1) SQL queries, say two or three.Hint: One query finds all movies matching the keyword; one query finds all directors of all movies matching the keyword; on query finds all the actors of all the movies matching the keyword. Execute each of these three queries separately. You then need to merge the results of the three queries *in* the Java code. The merge will be easier if your SQL queries sort the answers by the movie id. (There is also a way to write fastsearch with only two, or even only one single SQL query, but don't worry about that because it gets more messy with questionable benefits.) How much better should you expect fastsearch to be? We tried it on both a local installation of SQL Server and on SQL Azure. In the former case, fastsearch typically increases the speed very little: perhaps from 2-3 seconds to 1 second or so; with a cold cache the performance increase may be larger, from minutes, to several seconds.
Now, complete the application by implementing each of the followingtransactions. We call each action a transaction.You will need to write some of them as SQL transactions.Others are interactions with the database that do not require transactions.) The "login" transaction, which is run implicitly when you start your command line program, authenticating the user by his/her username and password. Much of the authentication logic is already provided in the starter code. For the most part, all you need to do is uncomment the code that performs the authentication and modify it to match your CUSTOMER schema.However, you must also establish a connection to your Customer database. You need to add code to do this. Look at how the starter code establishes a connection to the IMDB database. The "print customer info" transaction: To provide a minimum amount of user-friendliness, at each iteration of the program's main loop, you need to print the current customer's name, and tell them how many additional movies they can rent (given their current plan and the number of movies that they have already rented). The "plan" transaction. Here, the customer types the command plan PLAN_ID and you set her new plan to that plan id. How does the customer know which plan id's are available? They type in plan without any plan id, and then you will list all available plans, their names, and their terms (maximum number of movies available for rental and monthly fees). The "rent" transaction. The user types in rent MOVIE_ID, and you will "rent" that movie to the customer. The "return" transaction. The user types in return MOVIE_ID. You update your records to mark the return of that movie.Be sure to use SQL transactions when appropriate to implement these "transactions". See more on this below.Task 2D: Stop SQL Injection (10 points)Recall the search for example type:search NixonNow type this at the prompt:search ' and year=1899 -- What happens? You get all movies in 1899! Now type this: search '; drop movie; drop casts; drop actor; -- Actually, don't try it, you get the idea...This is SQL injection: hackers like to do it on Website interfaces to databases. Your task here is to fix the search and fastsearchfunction to prevent SQL injection attacks. Fix the security issue by changingthe code in Query.java (only). Hint: when fixing the issue,look at other parts of the starter code that execute SQL to see what they do differently from the broken search code.Transaction management (for Task 2C) You must use SQL transactionsin order to guarantee ACID properties: you must define begin- and end-transaction statements, and insert them in appropriate places in Query.java. In particular, you must ensure that the following two constraints are always satisfied, even if multiple instances of your application talk to the database.C1. at any time a movie can be rented to at most one customer.
2ff7e9595c
Comments