SQL for SQL Server 1 True/False Questions Chapter 2 Creating Tables and Indexes 1. In order to create a table, three pieces of information must be determined: (1) the table name, (2) the column names, and (3) the column data types. Answer: False Page Reference: 31 Difficulty: Easy 2. The NUMBER data type stores integer, fixed-point and floating-point, and monetary numbers. Answer: True Page Reference: 32 Difficulty: Hard 3. The default T-SQL date format is MM/DD/YY. Answer: False Page Reference: 36 Difficulty: Medium 4. Field names must include their table s name. For example, emp_ssn and emp_salary are fields in the emp table. Answer: False Page Reference: 38 Difficulty: Easy 5. Constraints are different types of data integrity. Answer: True Page Reference: 39 Difficulty: Easy 6. By default a PRIMARY KEY constraint is NOT NULL. Answer: True Page Reference: 40 Difficulty: Medium 7. The ALTER TABLE command can add a new column or modify an existing column. Answer: True Page Reference: 43 Difficulty: Medium 8. PRIMARY KEY constraints are used to enforce referential integrity. Answer: False Page Reference: 45 Difficulty: Easy 9. A FOREIGN KEY constraint cannot reference a column in a table that has not been created yet. Answer: True Page References: 45-46 Difficulty: Medium 10. The REFERENCES clause is required in a FOREIGN KEY constraint. Answer: True Page Reference: 47 Difficulty: Medium 11. By default the FOREIGN KEY constraint allows the user to delete rows that have associated dependent rows. Answer: False Page Reference: 47 Difficulty: Easy 12. The DELETE command is one of the simplest SQL statements, but can be very dangerous. Answer: True Page Reference: 52 Difficulty: Easy 13. The ALTER command changes the structure of a column, whereas the UPDATE command changes the contents of a column. Answer: True Page Reference: 52 Difficulty: Hard 14. The ROLLBACK command cancels operations to the database.
2 Chapter 2 Creating Tables and Indexes Answer: False Page Reference: 53 Difficulty: Hard 15. Indexes cannot be changed. Answer: True Page Reference: 58 Difficulty: Hard Multiple-Choice Questions 16. Numeric data not used for calculations should be stored in a column of what data type? a. FLOAT b. INTEGER c. REAL d. VARCHAR Answer: D Page Reference: 33 Difficulty: Hard 17. The default data format in T-SQL is: a. MM/DD/YYYY b. DD/MM/YYYY c. MMM DD YYYY d. DD-MON-YYYY Answer: C Page Reference: 36 Difficulty: Medium 18. A column or set of columns that uniquely identifies a row. a. Foreign key b. Primary key c. Secondary key d. Unique key Answer: B Page Reference: 39 Difficulty: Easy 19. A constraint that requires that the data values stored in a specific column must fall within some acceptable range of values. a. CHECK constraint b. NOT NULL constraint c. PRIMARY KEY constraint d. UNIQUE constraint Answer: A Page Reference: 40 Difficulty: Medium 20. Which of the following is NOT possible using the ALTER TABLE command? a. Add a new field b. Drop an existing field c. Modify the datatype of an existing field d. Change the name of an existing field Answer: D Page Reference: 44 Difficulty: Hard 21. A column or set of columns used to enforce referential integrity. a. Foreign key b. Primary key c. Secondary key d. Unique key Answer: A Page Reference: 47 Difficulty: Easy
SQL for SQL Server 3 22. Which of the following is NOT a valid optional clause in a FOREIGN KEY constraint? a. On Delete Cascade b. On Delete Modify c. On Delete No Action d. On Update Cascade Answer: B Page Reference: 47 Difficulty: Hard 23. A SQL command that removes a database object. a. DELETE b. DROP c. REMOVE d. TRUCATE Answer: B Page Reference: 50 Difficulty: Medium 24. A SQL command that adds a database object. a. ADD b. CREATE c. INSERT d. MAKE Answer: B Page Reference: 38 Difficulty: Medium 25. A SQL command that changes a database object. a. ALTER b. MODIFY c. REVISE d. UPDATE Answer: A Page Reference: 43 Difficulty: Medium 26. A SQL command that changes one or more values in a row. a. ALTER b. MODIFY c. REVISE d. UPDATE Answer: D Page Reference: 52 Difficulty: Medium 27. A SQL command that removes one or more rows. a. DELETE b. DROP c. REMOVE d. TRUCATE Answer: A Page Reference: 52 Difficulty: Medium 28. A SQL command that adds a row. a. ADD b. CREATE c. INSERT d. MAKE Answer: C Page Reference: 51 Difficulty: Medium 29. Which of the following is NOT a type of limitation on indexes? a. The maximum size of an index entry. b. The maximum number of columns in a composite index.
4 Chapter 2 Creating Tables and Indexes c. The number of indexes per table. d. The kind of index only nonclustered are supported. Answer: D Page Reference: 55 Difficulty: Easy Essay Questions 30. Compare and contrast the CHAR and VARCHAR data types. Answer: Both data types store character data. However, the CHAR data type stores fixed-length data (padding it with blank spaces if necessary) and the VARCHAR data type stores variablelength data. Page Reference: 34 Difficulty: Easy 31. What is the TIMESTAMP data type used for? Answer: The TIMESTAMP data type is used to determine the relative time when a data row was last modified or when a data row was initially created. Page Reference: 37 Difficulty: Medium 32. Briefly describe each of the four types of integrity constraints. Answer: The NOT NULL constraint means that a row of data must have a value for the column specified as NOT NULL. The UNIQUE constraint is used to enforce uniqueness for a column value. The CHECK constraint forces data values stored in a specific column to fall within some acceptable range of values. The PRIMARY KEY constraint is used to uniquely identify rows of data. Page References: 39-41 Difficulty: Hard 33. List at least three changes that can be made using the ALTER TABLE command. Answer: The ALTER TABLE command can: alter existing columns, add new columns, set default column values, disable and re-enable column constraints, and drop a column. Page Reference: 44 Difficulty: Hard 34. Describe referential integrity. Answer: Referential integrity stipulates that values of a foreign key must correspond to values of a primary key in the table that it references or be NULL. Page Reference: 47 Difficulty: Medium 35. Describe the three optional clauses in a FOREIGN KEY constraint. Answer: ON UPDATE CASCADE will propagate any update on the referenced table to the referencing table. ON DELETE CASCADE will propagate any deletion on the referenced table to the referencing table. ON DELETE NO ACTION will reject a deletion of a primary key value unless no foreign key references that value. Page Reference: 47 Difficulty: Hard 36. What is a composite primary key? Answer: A composite primary key is a primary key containing two or more columns in order to uniquely identify each row. Page Reference: 49 Difficulty: Medium 37. Briefly describe the SQL commands to populate, manipulate, and remove rows. Answer: The INSERT command adds a row to a table. The UPDATE command modifies an existing row. The DELETE command removes one or more rows from a table.
SQL for SQL Server 5 Page References: 51-52 Difficulty: Easy 38. How is updating a column different from modifying it? Answer: The ALTER command changes the table structure, but leaves the table data unaffected. The UPDATE command changes the table data, but not the table structure. Page Reference: 52 Difficulty: Medium 39. How are transactions handled in SQL Server by default? Answer: Unlike most relational DBMS products, SQL Server automatically commits after every INSERT, UDPATE, or DELETE operation. Page Reference: 53 Difficulty: Hard 40. What is a derived column? Answer: A derived or computed column where the values stored are derived by computations involving data stored in other columns in the table. Page References: 53-54 Difficulty: Hard 41. What is the primary benefit of an index? Answer: An index facilitates the rapid retrieval of information from tables. Page Reference: 54 Difficulty: Medium 42. What are the problems when using an index? Answer: All indexes on a table must be updated whenever a row is changed or deleted that is referenced by an index. Indexes also require disk space. Page References: 57-58 Difficulty: Medium