Chapter 9 Answers
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.
The process of removing duplicate data and optimizing tables is called normalization.
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.
To satisfy Second Normal Form, columns whose data repeats across multiple rows should be removed to their own tables.
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.
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.
To initiate a MySQL transaction, use either the
BEGINor theSTART TRANSACTIONcommand. To terminate a transaction and cancel all actions, issue aROLLBACKcommand. To terminate a transaction and commit all actions, issue aCOMMITcommand.To examine how a query will work in detail, you can use the
EXPLAINcommand.To back up the database
publicationsto a file called publications.sql, you would use a command such as:mysqldump -u ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access