Chapter 9 Answers

Question 9-1

The term relationship refers to the connection between two pieces of data that have some association, such as a book and its author, or a book and the customer who bought the book. A relational database such as MySQL specializes in storing and retrieving such relations.

Question 9-2

The process of removing duplicate data and optimizing tables is called normalization.

Question 9-3

The three rules of First Normal Form are: (1) There should be no repeating columns containing the same kind of data; (2) All columns should contain a single value; and (3) There should be a primary key to uniquely identify each row.

Question 9-4

To satisfy Second Normal Form, columns whose data repeats across multiple rows should be removed to their own tables.

Question 9-5

In a one-to-many relationship, the primary key from the table on the “one” side must be added as a separate column (a foreign key) to the table on the “many” side.

Question 9-6

To create a database with a many-to-many relationship, you create an intermediary table containing keys from two other tables. The other tables can then reference each other via the third.

Question 9-7

To initiate a MySQL transaction, use either the BEGIN or the START TRANSACTION command. To terminate a transaction and cancel all actions, issue a ROLLBACK command. To terminate a transaction and commit all actions, issue a COMMIT command.

Question 9-8

To examine how a query will work in detail, you can use the EXPLAIN command.

Question 9-9

To back ...

Get Learning PHP, MySQL, and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.