Docsity

D427 MySQL SQL Programming Intermediate 2026/2027: 107 Q&A, Exams of Computer Science

Toggle sidebar
bg1
Data Management - Applications D427 -
MYSQL - SQL Programing - Intermediate
Level
šŸ“‹
DOCUMENT OVERVIEW
Executive Exam Scope & Core Objectives 107 Questions
This document provides a comprehensive exam preparation pack containing 107 verified questions with
complete correct answers. It is curated to reinforce core syllabus principles, sharpen critical thinking, and support
effective revision, practice, and self-assessment for exam success.
āœ“
Verified Solutions
āœ“
100% Exam Ready
āœ“
Comprehensive Coverage
QUESTION 1
The Member table will have the following columns:
ID—positive integer
FirstName—variable-length string with up to 100 characters,
MiddleInitial—fixed-length string with 1 character,
LastName—variable-length string with up to 100 characters,
DateOfBirth—date,
AnnualPledge—positive decimal value representing a cost of up to $999,999, with 2 digits for cents,
Write a SQL statement to create the Member table.
Do not add any additional constraints to any column beyond what is stated.
CORRECT ANSWER
CREATE TABLE Member (
ID INT PRIMARY KEY unsigned,
FirstName VARCHAR(100),
MiddleInitial CHAR(1),
LastName VARCHAR(100),
DateOfBirth DATE,
AnnualPledge DECIMAL(8, 2) unsigned
);
QUESTION 2
100+ (2026⁄2027 Updated) Solved Exams + 100% Verified Solutions │ Complete Q&A
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21

Partial preview of the text

Download D427 MySQL SQL Programming Intermediate 2026/2027: 107 Q&A and more Exams Computer Science in PDF only on Docsity!

Data Management - Applications D427 -

MYSQL - SQL Programing - Intermediate

Level

šŸ“‹ DOCUMENT OVERVIEW Executive Exam Scope & Core Objectives 107 Questions

This document provides a comprehensive exam preparation pack containing 107 verified questions with complete correct answers. It is curated to reinforce core syllabus principles, sharpen critical thinking , and support effective revision , practice, and self-assessment for exam success.

āœ“ Verified Solutions āœ“ 100% Exam Ready āœ“ Comprehensive Coverage

QUESTION 1 The Member table will have the following columns: ID—positive integer FirstName—variable-length string with up to 100 characters, MiddleInitial—fixed-length string with 1 character, LastName—variable-length string with up to 100 characters, DateOfBirth—date, AnnualPledge—positive decimal value representing a cost of up to $999,999, with 2 digits for cents, Write a SQL statement to create the Member table. Do not add any additional constraints to any column beyond what is stated.

CORRECT ANSWER CREATE TABLE Member ( ID INT PRIMARY KEY unsigned, FirstName VARCHAR(100), MiddleInitial CHAR(1), LastName VARCHAR(100), DateOfBirth DATE, AnnualPledge DECIMAL(8, 2) unsigned );

QUESTION 2

100+ (2026⁄2027 Updated) Solved Exams + 100% Verified Solutions │ Complete Q&A

The Rating table has the following columns: RatingCode—variable-length string, primary key, RatingDescription—variable-length string, The Movie table should have the following columns: Title—variable-length string, maximum 30 characters, RatingCode—variable-length string, maximum 5 characters, Write a SQL statement to create the Movie table. Designate the RatingCode column in the Movie table as a foreign key to the RatingCode column in the Rating table.

CORRECT ANSWER

CREATE TABLE Movie ( Title VARCHAR(30), RatingCode VARCHAR(5), FOREIGN KEY (RatingCode) REFERENCES Rating(RatingCode) );

QUESTION 3

The Movie table has the following columns: ID—integer, primary key, Title—variable-length string, Genre—variable-length string, RatingCode—variable-length string, Year—integer, A new column must be added to the Movie table: Column name: Score, Data type: decimal(3,1), Write a SQL statement to add the Score column to the Movie table.

CORRECT ANSWER

ALTER TABLE Movie ADD Score DECIMAL(3, 1);

QUESTION 4

The Movie table has the following columns: ID—integer, primary key, Title—variable-length string, Genre—variable-length string, RatingCode—variable-length string, Year—integer, Write a SQL statement to create a view named MyMovies that contains the Title, Genre, and Year columns for all movies. Ensure your result set returns the columns in the order indicated.

The Movie table has the following columns: ID—integer, primary key, Title—variable-length string, Genre—variable-length string, RatingCode—variable-length string, Year—integer, Write a SQL statement to create an index named idx_year on the Year column of the Movie table.

CORRECT ANSWER

CREATE INDEX idx_year ON Movie (Year);

QUESTION 8

The Movie table has the following columns: ID—integer, primary key, auto-increment, Title—variable-length string, Genre—variable-length string, RatingCode—variable-length string, Year—integer, The following data needs to be added to the Movie table: Title Genre RatingCode Year, Pride and Prejudice Romance G 2005, Write a SQL statement to insert the indicated data into the Movie table.

CORRECT ANSWER

INSERT INTO Movie (Title, Genre, RatingCode, Year) VALUES ('Pride and Prejudice', 'Romance', 'G', 2005);

QUESTION 9

The Movie table has the following columns: ID—integer, primary key, Title—variable-length string, Genre—variable-length string, RatingCode—variable-length string, Year—integer, Write a SQL statement to delete the row with the ID value of 3 from the Movie table.

CORRECT ANSWER

DELETE FROM Movie WHERE ID = 3;

QUESTION 10

The Movie table has the following columns: ID—integer, primary key, Title—variable-length string, Genre—variable-length string, RatingCode—variable-length string, Year—integer, Write a SQL query to display all Title values in alphabetical order A-Z.

CORRECT ANSWER

SELECT Title FROM Movie ORDER BY Title ASC;

QUESTION 11

The Movie table has the following columns: ID—integer, primary key, Title—variable-length string, Genre—variable-length string, RatingCode—variable-length string, Year—integer, Write a SQL query to return how many movies have a Year value of 2019.

CORRECT ANSWER

SELECT COUNT(*) AS MovieCount FROM Movie WHERE Year = 2019;

QUESTION 12

The Movie table has the following columns: ID - integer, primary key, Title - variable-length string, Genre - variable-length string, RatingCode - variable-length string, Year - integer, The YearStats table has the following columns: Year - integer, TotalGross - bigint unsigned, Releases - integer, Write a SQL query to display both the Title and the TotalGross (if available) for all movies. Ensure your result set returns the columns in the order indicated.

CORRECT ANSWER

SELECT Movie.Title, YearStats.TotalGross FROM Movie LEFT JOIN YearStats ON Movie.Year = YearStats.Year;

CORRECT ANSWER

RESTRICT CONSTRAINT will reject the UPDATE if the input does not coincide with predetermined values and generates an error.

QUESTION 19

Which restrictions applies when using a materialized view?

CORRECT ANSWER

Materialized views require to be refreshed frequently and require more storage space.

QUESTION 20

Define a SELECT statement?

CORRECT ANSWER

SELECT column1, column2, ... FROM table_name;

QUESTION 21

Define a INSERT statement?

CORRECT ANSWER

INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);

QUESTION 22

Define a UPDATE statement?

CORRECT ANSWER

UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;

QUESTION 23

Define a DELETE statement?

CORRECT ANSWER

DELETE FROM table_name WHERE condition;

QUESTION 24

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?

CORRECT ANSWER

isbn_number

QUESTION 25

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 as the foreign key for the Book table?

CORRECT ANSWER

author_id

QUESTION 26

Which data type represents numbers with fractional values:

CORRECT ANSWER

DECIMAL

QUESTION 27

Which of the following is a DML command?

CORRECT ANSWER

INSERT, DELETE, UPDATE

QUESTION 28

QUESTION 31

What are some constraint facts about materialized view?

CORRECT ANSWER

It is stored and it must be refreshed whenever the base table changes.

QUESTION 32

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, Write a SQL statement to create the Customer table. Do not add any additional constraints to any column beyond what is stated.

CORRECT ANSWER

CREATE TABLE Customer ( CustomerID INT UNSIGNED, FirstName VARCHAR(50), MiddleInitial CHAR(1), LastName VARCHAR(50), DateOfBirth DATE, CreditLimit DECIMAL(7,2) UNSIGNED );

QUESTION 33

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.

CORRECT ANSWER

CREATE TABLE Book ( Title VARCHAR(30), GenreCode VARCHAR(5), FOREIGN KEY (GenreCode) REFERENCES Genre(GenreCode) );

QUESTION 34

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: decimal(3,1), Write a SQL statement to add the SafetyRating column to the Automobile table.

CORRECT ANSWER

ALTER TABLE Automobile ADD SafetyRating DECIMAL(3,1);

QUESTION 35

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 books. Ensure your result set returns the columns in the order indicated.

CORRECT ANSWER

CREATE VIEW MyBooks AS SELECT Title, Genre, Year FROM Book;

QUESTION 36

A database has a view named BookView. Write a SQL statement to delete the view named BookView from the database.

CORRECT ANSWER

DROP VIEW BookView;

QUESTION 37

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.

CORRECT ANSWER

INSERT INTO Book (Title, Genre, Year) VALUES ('The Joy Luck Club', 'Fiction', 1989);

QUESTION 41

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.

CORRECT ANSWER

DELETE from Book WHERE ID = 3;

QUESTION 42

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.

CORRECT ANSWER

UPDATE Book SET Year = 2022 WHERE Year = 2020;

QUESTION 43

Which query illustrates performing an outer join of the Book table with a different table?

CORRECT ANSWER

SELECT Book.Title, A.Author FROM Book B RIGHT JOIN Author A ON B.AuthorID = A.ID

QUESTION 44

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?

CORRECT ANSWER

Only rows in Tables A and B that share the join condition

QUESTION 45

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.

CORRECT ANSWER

SELECT * FROM Book;

QUESTION 46

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.

CORRECT ANSWER

SELECT Title, Genre FROM Book WHERE Year = 2020;

QUESTION 47

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.

CORRECT ANSWER

SELECT Title FROM Book ORDER BY Title ASC;

QUESTION 48

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 output the unique Genre values and the number of books with each genre value from the Book table as GenreCount. Sort the results by the Genre in alphabetical order A-Z. Ensure your result set returns the columns in the order indicated.

The Movie table has the following columns: ID - integer, primary key, Title - variable-length string, Genre - variable-length string, RatingCode - variable-length string, Year - integer, Write a SELECT statement to select the year and the total number of movies for that year. Hint: Use the COUNT() function and GROUP BY clause.

CORRECT ANSWER

SELECT Year, COUNT(*) AS TotalMovies FROM Movie GROUP BY Year;

QUESTION 52

The Movie table has the following columns: ID - integer, primary key, Title - variable-length string, Genre - variable-length string, RatingCode - variable-length string, Year - integer, The Rating table has the following columns: Code - variable-length string, primary key, Description - variable-length string, Write a SELECT statement to select the Title, Year, and rating Description. Display all movies, whether or not a RatingCode is available. Hint: Perform a LEFT JOIN on the Movie and Rating tables, matching the RatingCode and Code columns.

CORRECT ANSWER

SELECT Movie.Title, Movie.Year, Rating.Description FROM Movie LEFT JOIN Rating ON Movie.RatingCode = Rating.Code;

QUESTION 53

The Employee table has the following columns: ID - integer, primary key, FirstName - variable-length string, LastName - variable-length string, ManagerID - integer, Write a SELECT statement to show a list of all employees' first names and their managers' first names. List only employees that have a manager. Order the results by Employee first name. Use aliases to give the result columns distinctly different names, like "Employee" and "Manager". Hint: Join the Employee table to itself using INNER JOIN.

CORRECT ANSWER

SELECT E.FirstName AS Employee, M.FirstName AS Manager FROM Employee E JOIN Employee M ON E.ManagerID = M.ID ORDER BY E.FirstName;

QUESTION 54

The database has three tables for tracking horse-riding lessons: Horse with columns: ID - primary key, RegisteredName, Breed, Height, BirthDate, Student with columns: ID - primary key, FirstName, LastName, Street, City, State, Zip, Phone, EmailAddress, LessonSchedule with columns: HorseID - partial primary key, foreign key references Horse(ID), StudentID - foreign key references Student(ID), LessonDateTime - partial primary key, Write a SELECT statement to create a lesson schedule with the lesson date/time, horse ID, and the student's first and last names. Order the results in ascending order by lesson date/time, then by horse ID. Unassigned lesson times (student ID is NULL) should not appear in the schedule. Hint: Perform a join on the Student and LessonSchedule tables, matching the student IDs.

CORRECT ANSWER

SELECT LS.LessonDateTime, LS.HorseID, S.FirstName, S.LastName From LessonSchedule LS Join Student S on LS.StudentID = S.ID Where LS.StudentID is not Null Order BY LS.LessonDateTime ASC, LS.HorseID ASC;

QUESTION 55

CORRECT ANSWER

SELECT RegisteredName, Height From Horse Where Height > ( SELECT AVG(Height) From Horse ) Order By Height ASC;

QUESTION 57

The Movie table has the following columns: ID - positive integer, Title - variable-length string, Genre - variable-length string, RatingCode - variable-length string, Year - integer, Write ALTER statements to make the following modifications to the Movie table: Add a Producer column with VARCHAR data type (max 50 chars). Remove the Genre column. Change the Year column's name to ReleaseYear, and change the data type to SMALLINT.

CORRECT ANSWER

ALTER Table Movie ADD Producer Varchar(50), Drop Genre, CHANGE Year ReleaseYear SMALLINT;

QUESTION 58

The Horse table has the following columns: ID - integer, auto increment, primary key, RegisteredName - variable-length string, Breed - variable-length string, must be one of the following: Egyptian Arab, Holsteiner, Quarter Horse, Paint, Saddlebred, Height - decimal number, must be between 10.0 and 20.0, BirthDate - date, must be on or after Jan 1, 2015, Insert the following data into the Horse table: RegisteredName, Breed, Height, BirthDate, Babe, Quarter Horse, 15.3, 2015-02-10, Independence, Holsteiner, 16.0, 2017-03-13, Ellie, Saddlebred, 15.0, 2016-12-22, NULL, Egyptian Arab, 14.9, 2019-10-12,

CORRECT ANSWER

INSERT INTO Horse (RegisteredName, Breed, Height, BirthDate) VALUES ('Babe', 'Quarter Horse', 15.3, '2015-02-10'), ('Independence', 'Holsteiner', 16.0, '2017-03-13'), ('Ellie', 'Saddlebred', 15.0, '2016-12-22'), (NULL, 'Egyptian Arab', 14.9, '2019-10-12');

QUESTION 59

The Horse table has the following columns: ID - integer, auto increment, primary key, RegisteredName - variable-length string, Breed - variable-length string, must be one of the following: Egyptian Arab, Holsteiner, Quarter Horse, Paint, Saddlebred, Height - decimal number, must be ≄ 10.0 and ≤ 20.0, BirthDate - date, must be ≄ Jan 1, 2015, Make the following updates: Change the height to 15.6 for horse with ID 2. Change the registered name to Lady Luck and birth date to May 1, 2015 for horse with ID 4. Change every horse breed to NULL for horses born on or after December 22, 2016.

CORRECT ANSWER

UPDATE Horse SET Height = 15. WHERE ID = 2; UPDATE Horse SET RegisteredName = 'Lady Luck', BirthDate = '2015-05-01' WHERE ID = 4; UPDATE Horse SET Breed = NULL WHERE BirthDate >= '2016-12-22';

QUESTION 60

The Horse table has the following columns: ID - integer, auto increment, primary key, RegisteredName - variable-length string, Breed - variable-length string, Height - decimal number, BirthDate - date, Delete the following rows: Horse with ID 5. All horses with breed Holsteiner or Paint. All horses born before March 13, 2013.