


































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A comprehensive set of sql statements and queries related to database management, including creating tables, establishing foreign key relationships, modifying table structures, inserting and deleting data, and performing advanced queries. The content focuses on managing a book database with tables for books, genres, and sales data. It demonstrates how to leverage sql to effectively manage data, maintain data integrity, and extract valuable insights from the database. A solid foundation for understanding sql concepts and their practical application in real-world database scenarios, making it a valuable resource for students, developers, and database administrators alike.
Typology: Exams
1 / 42
This page cannot be seen from the preview
Don't miss anything!



































lOMoARcPSD|43502630lOMoARcPSD|
D427 Practice Test
c. author_id d. isbn_number
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.
FOREIGN KEY (customer_id) REFERENCES Customer (customer_id) ON DELETE SET TO NULL ); 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.
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.
The Customer table will have the following columns: Customer ID—positive integer First Name—variable-length string with up to 50 characters Middle Initial—fixed-length string with 1 character
A new column must be added to the Automobile table: Column name: Safety Rating Data type: decimal (3,1) Write a SQL statement to add the Safety Rating column to the Automobile table.
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 movies. Ensure your result set returns the columns in the order indicated.
A database has a view named Book View. Write a SQL statement to delete the view named Book View from the database.
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 modify the Book table to make the ID column the primary key.
The Year Sales table has the following columns: Year—integer Total Sales—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 Year Sales table.
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.
The Book table has the following columns: ID—integer, primary key, auto _increment Title—variable-length string Genre—variable-length string Year—integer The following data needs to be added to the Book table: Title Genre Year The Joy Luck Club Fiction 1989 Write a SQL statement to insert the indicated data into the Book table.
The Book table has the following columns: ID—integer, primary key, auto_increment Title—variable- length string Genre—variable- length string Year—integer Write a SQL statement to delete the row with the ID value of 3 from the Book table.
The Book table has the following columns: ID—integer, primary key, auto_increment Title—variable- length string Genre—variable- length string Year—integer Write a SQL statement to update the Year value to be 2022 for all books with a Year value of 2020.
Assume there are two tables, A and B. Which rows will always be included in the result set if Table A is inner joined with Table B? a. Only rows in Tables A and B that share the join condition b. All rows in Table B c. All rows in Table A d. Only rows in Tables A and B that do not share the join condition.
The database contains a table named Book. Write a SQL query to return all data from the Book table without directly referencing any column names.
The Book table has the following columns: ID—integer, primary key, auto_increment Title—variable- length string Genre—variable- length string Year—integer Write a SQL query to retrieve the Title and Genre values for all records in the Book table with a Year value of 2020. Ensure your result set returns the columns in the order indicated.
The Book table has the following columns: ID—integer, primary key, auto_increment Title—variable- length string Genre—variable- length string Year—integer Write a SQL query to display all Title values in alphabetical order A–Z.
Continued below
The Book table has the following columns: ID—integer, primary key, auto_increment Title—variable- length string Genre—variable- length string Year—integer Write a SQL query to return how many books have a Year value of 2019.
D427 Practice Test ANSWER KEY