I. Study Guide: A. General Guideline: 1. Study the summary in each chapter. 2. Study the lecture notes. 3. Study those sample codes shown in the class. 4. Study the textbook. 5. Do the review questions and exercises. B. Review for the Test 2: 1. Understand the basic terminologies. 2. Understand the Web server operation. (Chap 11) 3. Understand the Apache Web server. (Chap 11) 4. Understand basic Java language and applets. (Appendix A) 5. Understand relational databases. (Chap 13) 6. Understand basic SQL. (Chap 13) 7. Understand database access with Perl and MySQL. (Chap 13) II. Sample Questions: A. Multiple Choice Questions: (a) 1. Which file stores the directives that control an Apache server's behavior? (a) httpd.conf (b) srm.conf (c) access.conf (d) ssl.conf (c) 2. Which directive is used to spcify the document root for the Apache server? (a) DirectoryIndex (b) ServerRoot (c) DocumentRoot (d) ScriptAlias (b) 3. Which cookie parameter is used to specify the experation time of a cookie? (a) expiredtime (b) expires (c) setTime (d) setLife (d) 4. To insert a new line between the printing of two values using println in Java, we need (a) + "n" + (b) newline() (c) "\n" (d) + "\n" + (b) 5. Which class reads text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines? (a) FileInputStream (b) BufferedReader (c) InputStreamReader (d) File (c) 6. To add 10 to points, we would use: (a) points + 10 (b) points ++ 10 (c) points += 10 (d) points =+ 10 (c) 7. Which SQL command is used to change one or more of the values of a row of a table? (a) change (b) modify (c) update (d) join (a) 8. In MySQL, which command is used to show tables in the database? (a) show tables (b) display tables (c) describe tables (d) demo tables (d) 9. Which method in DBI is used to create a compiled version of a SQL command? (a) compile (b) execute (c) generate (d) prepare B. Question & Answer: 1. Terminologies: 1. Virtual Host 2. Proxy Server 3. Cookie 4. SQL 5. ODBC - Open Database Connectivity 2. Consider the following Java code. Write the results after running the code in the command line java Hello Aloha John public class Hello { public static void main (String[] args) { System.out.println("Hello World " + args[0] + " " + args[1]); } } Ans: Hello World Aloha John 3. Explain third-tier architecture of a Web site supported by databases. Ans: +-----------------+ +----------------------+ +----------+ | Database Client |----->| Web Server and |---->| Database | | (Browser) |<-----|Database Applications |<----| System | +-----------------+ +----------------------+ +----------+ 1) The first tier has the Web browser, which provides the user interface. 2) The middle tier has Web server and the applications that require database access. 3) The third tier has the database system and the database itself. 4. Use the SQL command to create a table specifying a course including the following information: the course identification, the course title, the credit hours, the instructor, the schedule, and the classroom. Ans: create table course ( course_id varchar(10), course_title varchar(25), hours integer, instructor varchar(25), schedule varchar(15), classroom varchar(19) ); 5. Consider the following two database tables. Use the SQL command to get a list the first name and last name of customers who have more than $5000 in their account. Coustomer table: +-------------+-----------+----------+------------+ | customer_no | firstname | lastname | account_no | +-------------+-----------+----------+------------+ | 1 | Mike | Nichols | 102 | | 2 | Jay | Leno | 202 | | 3 | John | Wayne | 302 | | 4 | Tim | Allen | 402 | +-------------+-----------+----------+------------+ Account: +------------+---------+ | account_no | balance | +------------+---------+ | 102 | 5000.00 | | 202 | 7000.00 | | 302 | 6000.00 | | 402 | 4000.00 | +------------+---------+ Ans: select firstname, lastname from Customer, Account where Customer.account_no = Account.account_no and balance > 5000; 6. Complete the following Perl program which displays all rows of a table in a MySQL database as spcified as below: 1. Host name: kirk 2. Account name: cs655 3. Password: abc123 4. Database: cs655 5. The fields of the Friend table: +-----------+-------------+ | Field | Type | +-----------+-------------+ | firstname | varchar(15) | | lastname | varchar(20) | | city | varchar(15) | | state | char(2) | | age | int(11) | +-----------+-------------+ Ans: #!/usr/bin/perl use DBI; my $host = "kirk"; my $user = "cs655"; my $password = "abc123"; my $dbname = "cs655"; my $dbh = DBI->connect("dbi:mysql:dbname=$dbname:host=$host", $user, $password); $dbh or die "cannot connect to the database:$!\n"; my @tables = $dbh->tables; # return tables in the "cs 655" database. print "@tables\n"; # print tables # prepare the command my $sth = $dbh->prepare ("select * from Friend"); $sth->execute(); # execute the command # retrieve the result using the fetchrow_arrayref function which # return the address of the array while (my $data = $sth->fetchrow_arrayref ()) { my ($fname, $lname, $city, $state, $age) = @$data; print "First Name: $fname\n"; print "Last Name: $lname\n"; print "City: $city\n"; print "State: $state\n"; print "Age: $age\n"; print "\n"; } $sth->finish (); # done with the command $dbh->disconnect; # disconnect the database print "bye\n";