Quiz #2 -- The Airplane Quiz

1) Read this program carefully.  What does this program print?  What's in the first column, the second column, the third column, etc.?

#!/usr/bin/perl
my($name, $age);
use DBI;
$dbh = DBI->connect("DBI:mysql:fred", "tom", "steve");
$dbh->do("select name from people where age > 100 order by age");
$sth = $dbh->prepare("select age, name from people where name > 'z' order by name");
$sth->execute();
$sth->bind_columns(undef, \$name, \$age);
while ($sth->fetch) {
    print "$name $age\n";
}
$dbh->disconnect;
2) Suppose the database daemon for MySQL was not running when this program ran?  What line would fail?

3) Which of these is the slowest DBI call for the types of queries run in class?

The sth->prepare
The sth->execute
The sth->fetch
The dbh->connect
4) (Yes/no) Is there a DBI for C++?  I'm not asking if there is SOME interface to the database via C++, but one named DBI with calls like connect, execute, etc.

5) Suppose you want to delete a table and all the data in contains.  It's not an already empty table.   Write me a DBI/Perl program to do this.

6) Which of these statements are suitable for dbh->do?  Circle all that apply

select * from people
create table people(name char(30) not null, age int)
insert into people values ("dan", 20)
7) (True/false)  Suppose VISA runs a transaction on their database.  At the same time VISA runs a second transaction. There is NO WAY that the second transaction is effected by the first, assuming that both transactions run correctly, the database is working properly, etc.
Remove $100 from your account
Add $100 to my account
Sum = 0
Sum = Sum + Your_Account_Balance
Sum = Sum + My_Account_Balance
8) Suppose table 1 has 1000 rows and 8 columns,  Ten of the rows have name = 'fred'.  Table 2 has 500 rows and 6 entries with age =7.  How many answer rows does this querry generate?
select * from tabel1 A, table2, table1 B where age = 7 and A.name = 'fred';