D427 Practice Test 1 with Answer Key

.docx

School

Western Governors University *

*We aren’t endorsed by this school

Course

427

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

23

Uploaded by UltraElementLoris27

Report
D427 Practice Test 1 1. Seattle, WA 98111 USA How many attributes are present in the address fragment? a. 1 b. 2 c. 3 d. 4 2. The Book table has the following columns: genre – varchar(20) pages – integer author_id – char(3) isbn_number – varchar(20) Which column should be designated at the primary key for the Book table? a. genre b. pages c. author_id d. isbn_number 3. The Book table has the following columns: genre – varchar(20) pages – integer author_id – char(3) isbn_number – varchar(20) Which column should be designated at the foreign key for the Book table? a. genre b. pages c. author_id d. isbn_number 4. Which data type represents numbers with fractional values: a. Integer b. Decimal c. Character d. Binary
5. Which of the following are DDL commands? a. INSERT b. SELECT c. CREATE INDEX d. UPDATE 6. Which of the following is a DML command? a. CREATE VIEW b. CREATE TABLE c. INSERT d. ALTER INDEX 7. CREATE TABLE Invoice ( invoice_id INT NOT NULL AUTO_INCREMENT, date DATE NOT NULL, customer_id INT NOT NULL, PRIMARY KEY (invoice_id), FOREIGN KEY (customer_id) REFERENCES Customer (customer_id) ON DELETE CASCADE ); Looking at the Customer and Invoice tables and the CREATE TABLE for the Invoice table with foreign key reference statement above, what would happen to invoices in the Invoice table that are linked to a customer if that customer is deleted. a. Those invoices would remain in the database. b. Those invoices would be deleted also. c. The Customer ID for those invoices would be changed to NULL. d. Nothing would happen. 8. Invoice ID (PK) Date Customer ID (FK) Customer ID (PK) Customer Last Name Customer First Name Street Address City State Zip
CREATE TABLE Invoice ( invoice_id INT NOT NULL AUTO_INCREMENT, date DATE NOT NULL, customer_id INT NOT NULL, PRIMARY KEY (invoice_id), FOREIGN KEY (customer_id) REFERENCES Customer (customer_id) ON DELETE RESTRICT ); Looking at the Customer and Invoice tables and the CREATE TABLE for the Invoice table with foreign key reference statement above, what would happen to invoices in the Invoice table that are linked to a customer if that customer is deleted. a. Those invoices would remain in the database. b. Those invoices would be deleted also. c. The Customer ID for those invoices would be changed to NULL. d. The delete of the Customer would not be allowed. 9. CREATE TABLE Invoice ( invoice_id INT NOT NULL AUTO_INCREMENT, date DATE NOT NULL, customer_id INT NOT NULL, PRIMARY KEY (invoice_id), FOREIGN KEY (customer_id) REFERENCES Customer (customer_id) ON DELETE SET TO NULL Invoice ID (PK) Date Customer ID (FK) Customer ID (PK) Customer Last Name Customer First Name Street Address City State Zip
); Looking at the Customer and Invoice tables and the CREATE TABLE for the Invoice table with foreign key reference statement above, what would happen to invoices in the Invoice table that are linked to a customer if that customer is deleted. e. Those invoices would remain in the database. f. Those invoices would be deleted also. g. The Customer ID for those invoices would be changed to NULL. h. The delete of the Customer would not be allowed. 10. Which of the following are true about materialized view (Choose 2)? a. It is a base table. b. It is stored. c. It must be refreshed whenever the base table changes. d. The results are stored as a temporary table. 11. The   Customer   table will have the following columns: CustomerID—positive integer FirstName—variable-length string with up to 50 characters MiddleInitial—fixed-length string with 1 character LastName—variable-length string with up to 50 characters DateOfBirth—date CreditLimit—positive decimal value representing a cost of up to $19,999, with 2 digits for cents Invoice ID (PK) Date Customer ID (FK) Customer ID (PK) Customer Last Name Customer First Name Street Address City State Zip
Write a SQL statement to create the   Customer   table. Do not add any additional constraints to any column beyond what is stated. 12. The   Genre   table has the following columns: GenreCode—variable-length string, primary key GenreDescription—variable-length string The   Book   table should have the following columns: Title—variable-length string, maximum 30 characters GenreCode—variable-length string, maximum 5 characters Write a SQL statement to create the   Book   table. Designate the   GenreCode   column in the   Book   table as a foreign key to the   GenreCode   column in the   Genre   table. 13. The   Automobile   table has the following columns: ID—integer, primary key Make—variable-length string Model—variable-length string Year—integer A new column must be added to the   Automobile   table: Column name:   SafetyRating Data type: A positive number that is less than 80 with 1 decimal space. Write a SQL statement to add the   SafetyRating   column to the   Automobile   table 14. The   Book   table has the following columns: ID—integer, primary key Title—variable-length string Genre—variable-length string Year—integer Write a SQL statement to create a view named   MyBooks   that contains the   Title,   Genre, and   Year   columns for all books. Ensure your result set returns the columns in the order indicated.
15. A database has a view named   BookView. Write a SQL statement to delete the view named   BookView   from the database.   16. The   Book   table has the following columns: ID—integer Title—variable-length string Genre—variable-length string Year—integer Write a SQL statement to modify the   Book   table to make the   ID   column the primary key. 17. The   Book   table has the following columns: ID—integer, primary key Title—variable-length string Genre—variable-length string Year—integer The   YearSales   table has the following columns: Year—integer TotalSales—bigint unsigned Releases—integer Write a SQL statement to designate the   Year   column in the   Book   table as a foreign key to the   Year   column in the   YearSales   table.   18. The   Book   table has the following columns: ID—integer, primary key Title—variable-length string Genre—variable-length string Year—integer Write a SQL statement to create an index named   idx_year   on the   Year   column of the   Book   table.  
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help