Professional Documents
Culture Documents
2. Which of the following features is supported by both the mysql and mysqli PHP
extensions?
1. multi-query
2. object-oriented programming interface
3. procedural programming interface
4. prepared statements
5. transactions
6. no answer
ANS: 3
3. Which of the following is a correct PDO DSN for connecting to a MySQL database
named People?
1. mysql;host=localhost:3306,db=People
2. mysql:host=localhost;port=3306;dbname=People
3. mysql://host=localhost,port=3306,dbname=People
4. mysql:host=localhost;port=3306;db=People
5. mysql:hostname=localhost,port=3306,db=People
6. no answer
ANS: 2
1. issue the same SQL query multiple times but with different parameter values
2. query a MySQL server using functions from the mysql extension
3. speed up a single query that searches through the values of a certain column from
an SQL table
4. design the table structure of a future SQL database
5. create a group of SQL statements that will execute atomically (they must all
succeed, or the whole operation fails)
6. no answer
ANS: 1
5. Which of the following are true about the following SQL query, if the Products table
has 3 columns and 6 records and the Categories table has 2 columns and 3 records?
(choose three)
SELECT * FROM Products,Categories;
6. Which code fragment could be used after the sequence below in order to display the
list of names extracted from an SQL table named People? (choose three):
try{
$pdo = new PDO('mysql:host=localhost;dbname='Beings','user','pass');
}catch(PDOException $e){
die("An error has occured: ".$e->getMessage());
}
// next is the code for extracting and displaying the people's names
???
1. $r = $pdo->query("SELECT * FROM People");
$s = $r->fetchAll(PDO::FETCH_ASSOC);
foreach($s as $p)
echo $p['Name']."<br />";
2. $r = $pdo->query("SELECT * FROM People");
foreach($s = $r->fetch(PDO::FETCH_ASSOC))
echo $s['Name']."<br>";
3. foreach($pdo->query("SELECT * FROM people") as $s)
echo $s['Name']."<br>";
4. $r = $pdo->query("SELECT * FROM People");
while($s = $r->fetch(PDO::FETCH_NUM))
echo $s['Name']."<br>";
5. $r = $pdo->query("SELECT * FROM People");
while($s = $r->fetch(PDO::FETCH_ASSOC))
echo $s['Name']."<br>";
ANS: 1, 3, 5
7. An SQL table column whose values refer to the primary key from another table is
called:
1. unique index
2. primary key
3. exported index
4. linked column
5. foreign key
6. no answer
ANS: 5
8. Which of the following are true about the SQL query below? (choose two)
SELECT * FROM Categories LEFT JOIN Products ON (Product.ID = Categories.Produc
tID)
1. if a category has no matching products, it will still be displayed in the result,
but the columns corresponding to the Products table will contain the NULL
value
2. the result will always contain all the records from the Categories table
3. if a category has no matching products, it will not be included in the query result
4. the query will only select records that have NULL on the ProductID column
5. the result will always contain all the records from the Products table
ANS: 1, 2
9. Which of the following are true about M-to-N relationships between two SQL tables?
(choose three)
10. Which of the following are valid ways of creating an SQL table named People that
has a unique index on the Name column? (choose three)
1. CREATE TABLE People(Name VARCHAR(50) NOT NULL ADD INDEX UNI
QUE, Age INT);
2. CREATE TABLE People (Name VARCHAR(50) NOT NULL, Age INT);
ALTER TABLE People ADD UNIQUE(Name);
3. CREATE TABLE People(Name VARCHAR(50) NOT NULL INDEX TYPE UNI
QUE, Age INT);
4. CREATE TABLE People (Name VARCHAR(50) NOT NULL UNIQUE, Age
INT);
5. CREATE TABLE People (Name VARCHAR(50) NOT NULL, Age INT);
CREATE UNIQUE INDEX Name ON People(Name);
ANS: 2, 4, 5
11. The PHP programmer can NOT work with a MySQL database using:
12. What will the following code sequence display in the browser when executed via a
web server?
$c = new mysqli('localhost', 'user', 'pass', 'db');
$sql = "SELECT * FROM People";
$result = mysqli_query($sql);
while($p = mysqli_fetch_assoc($r))
echo "$p[name]\n";
1. an error, because the correct syntax for the last line should have been echo
"$p['name']\n";
2. an error, because the constructor of the mysqli class only accepts 3 arguments
3. an error, because the mysqli_query() function must receive the connection
identifier as its first argument
4. a list of people names, one on each line
5. a list of people names, one after another on one line
6. no answe
ANS: 3
13. Which of the following are advantages of using indexes in SQL tables? (choose two)
1. increased speed when issuing INSERT queries that add data to an indexed
column
2. increased speed of SELECT statements having WHERE clauses that refer to
indexed columns
3. less space occupied by SQL tables that contain indexes
4. increased speed when deleting data from an SQL table that contains indexed
columns
5. increased speed when sorting query results (using ORDER BY) according to
an indexed column
ANS: 2, 5
14. Which of the following correctly describe the predefined classes from the mysqli
extension? (choose three)