In: Computer Science
MySQL
Multiple Choice
Answer as soon as possible
1. Why is it important to check the replication
status regularly by running SHOW SLAVE STATUS on the slave?
(a) Running SHOW SLAVE STATUS cleans up the binary and relay logs
that are not in use.
(b) Running SHOW SLAVE STATUS syncs all tables where the data is
different from the Master and Slave.
(c) Replication can have an error at any time and if you don't run
SHOW SLAVE STATUS regularly you may not realize for a long
time.
(d) It is not important to run SHOW SLAVE STATUS to check
replication status.
2. Why is it important for an uptime monitoring
service to check your website from multiple servers around the
world, before considering your website down?
(a) Localized network errors may cause false alarms from individual
servers.
(b) You often only need to have your website available from
specific locations so you don't need to check it from locations
around the world.
(c) It is not important. Checking your website from fewer servers
will save greatly on electricity.
(d) It is not important. You can confirm a website is down from an
individual server accurately.
3. Which of the following are correct regaring
PHP's MySQLi and PDO connections to MySQL? (select all that
apply)
(a) MySQLi offers a procedural API.
(b) PDO works only with MySQL.
(c) PDO and MySQLi both offer object-oriented APIs.
(d) PDO has an exception class to handle any problems that may
occur in our database queries.
(e) Only PDO offers prepared statements.
(f) Both PDO and MySQLi offer protection against SQL Injection
Attacks.
Q.1
The correct option is (c). Running SHOW SLAVE STATUS periodically is very important. It helps in identifying the log files that have errors and aids in cleaning them.
Q.2
The correct option is (a). This is because nowadays all websites have customers all around the world. Hence it becomes important that we have multiple checkpoints around the world so that it minimizes revenue losses. Moreover Localized network errors are prone to cause false alarms from individual servers.
Q.3
(a) This option is correct. MySQLi offers both Procedural and Object Oriented APIs.
(b) This option is incorrect. PDO works with 12 different database drivers out of which MySQL is one.
(c) This option is correct. Both PDO and MySQLi offer OOP APIs. MySQLi additionally offers procedural APIs as well.
(d) This option is correct. The class used for exception handling is PDOException class which is inherited from the RuntimeException class.
(e) This option is incorrect. Both PDO and MySQLi offer prepared statements.
(f) This option is correct. Both PDO and MySQLi offer prepared statements that offer protection against SQL Injection attacks.
Hence (a), (c), (d), (f) are correct options.