Sams Teach Yourself SQL in 24 Hours, Third Edition By Ronald R. Plew, Ryan K. Stephens
Table of Contents
Appendix C. Answers to Quizzes and Exercises
Hour 1, "Welcome to the World of SQL"
Quiz Answers
1:
What does the acronym SQL stand for?
A1:
SQL stands for Structured Query Language.
2:
What are the six main categories of SQL commands?
A2:
Data Definition Language (DDL)
Data Manipulation Language (DML)
Data Query Language (DQL)
Data Control Language (DCL)
Data Administration Commands (DAC)
Transactional Control Commands (TCC)
3:
What are the four transactional control commands?
A3:
COMMIT
ROLLBACK
SAVEPOINT
SET TRANSACTIONS
4:
What is the main difference between client/server and Web technologies as they related to database access?
A4:
The connection to the database would be the main difference. Using the client to connect would log on to the server directly to the database. When using the Web, you log on to the Internet to reach the database.
5:
If a field is defined as NULL, does that mean that something has to be entered into that field?
A5:
No. If a column is defined as NULL, nothing has to be in the column. If a column is defined as NOT NULL, something has to be entered.
Exercise Answers
1:
Identify the categories in which the following SQL commands fall:
CREATE TABLE DELETE SELECT INSERT ALTER TABLE UPDATE
A1:
CREATE TABLE DDL, Data Definition Language
DELETE DML, Data Manipulation Language
SELECT DQL, Data Query Language
INSERT DML, Data Manipulation Language
ALTER TABLE DDL, Data Definition Language
UPDATE DML, Data Manipulation Language
2:
Study the following tables and pick out the column that would be a good candidate for the primary key:
EMPLOYEE_TBL
INVENTORY_TBL
EQUIPMENT_TBL
name
item
model
phone
description
year
start date
quantity
serial number
address
item number
equipment number
employee number
location
assigned to
A2:
The primary key for the employee_tbl would be the employee number. Each employee is assigned a unique employee number. Employees could have the same name, phone, start date, and address.
The primary key for the inventory_tbl would be the item number. The other columns could possibly be duplicated .
The primary key for the equipment_tbl would be the equipment number. Once again, the other columns could be duplicated.
3:
Refer to Appendix B,"Using MySQL for Exercises." Download and install MySQL on your computer to prepare for hands-on exercises in the following hours of instruction.