You are on page 1of 6

SQL Essential

T ra ining Te st

Document Code 25e-BM/HR/HDCV/FSOFT

Version 1.1

Effective Date 02/05/2019

Hanoi, 05/2019
Training Test SQL Essential Issue/Revision: 1/1

RECORD OF CHANGES

No Effective Date Change Description Reason Reviewer Approver

1 05/2019 Create new A TuTB VinhNV

2 07/2019 Update requirements and correct M TuTB VinhNV


spelling

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 2/6


Training Test SQL Essential Issue/Revision: 1/1

Contents
For the following exam:.............................................................................................................. 4
SQL Essential - Final Test ......................................................................................................... 4

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 3/6


Training Test SQL Essential Issue/Revision: 1/1

CODE: SQLE.Practice.T01
FPT SOFTWARE
Test topic : SQL Essential
ACADEMY
Test duration : 180 minutes

For the following exam:


• Print out respectively the screenshots to show the query results.

• Pack screenshots and SQL scripts or your answers into the zip file named
SQLE_FinalTest_AccountName.zip (for instance: SQLE_FinalTest_NamNT.zip) then handle
to the evaluator via email (XYZ@fsoft.com.vn ) or follow the guidance of the class admin.

SQL Essential - Final Test


Barem: Qa - 40%, Qb – 10%, Qc – 10%, Qd - 10%, Qe – 15%, Qf - 15%.

Objective: K3SD- RDBMS and H4SD- SQL skills

Problem Description:

You work as a Database Developer for Guitar Shop. The shop is going to design their own database.
ERD for the future database as below.

As shown, the Project database contains five tables: Categories, Products, Orders, Customers and
OrderItems.

Categories has attributes:

• CategoryID: an auto-generated number (identity) as primary key

• CategoryName: name of category, must be unique and cannot be null

Products has attributes:

• ProductID: an autogenerated number (identity) as primary key

• CategoryID: foreign key, reference to CategoryID of Categories table

• ProductCode: always has 10 characters, must be unique and cannot be null

• ProductName: should be a string in English, cannot be null

• Description: max 500 characters, cannot be null, allow multiple lines

• DateAdded: the added date of that product

Customers has attributes:

• CustomerID: an auto-generated number (identity) as primary key

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 4/6


Training Test SQL Essential Issue/Revision: 1/1

• Email: email address of customer, must be unique and cannot be null

• Password: password of customer, cannot be null

• FirstName: should be a string in any language, cannot be null

• LastName: should be a string in any language, cannot be null

• Address: address of customer, can be null

• IsPasswordChanged: bit type, default is false.

Orders has attributes:

• OrderID: an auto-generated number (identity) as primary key

• CustomerID: foreign key, reference to CustomerID of Customers table

• OrderDate: cannot be null

• ShipAddress: should be a string and allow multiple lines.

OrderItems has attributes:

• OrderID: foreign key, reference to OrderID of Orders table

• ProductID: foreign key, reference to ProductID of Products table

• Quantity: cannot be null, negative value only

• UnitPrice: money type, cannot be null

• DiscountPercent: decimal type, cannot be null, value in range from 0.00 to 75.00

Questions to answer:

Note: Following coding convention and has appropriate comments.

a. Create a database called GuitarShopDB, then:

- Create the tables with the most appropriate column constraints & types.

- Add at least 4 records for Categories, and add at least 10 records for Products, Orders,
Customers and OrderItems.

b. Write a query to select ProductCode, ProductName, Description and DateAdded from Products
table. The query returns product(s) added at least 12 months ago and sort older products on top

c. Write a query to update data in Customers table. Change the password to “Secret’@1234!” for the
customer with an email address of “rick@raven.com” and IsPasswordChanged is false.

d. Write a query to return [Full Name] from Customers table. Data of [Full Name] column is combined
from the LastName and FirstName column with format: the last name, a comma, a space, and the
first name. Example: “Stark, Tony”.

Sort the result set by last name in ascending sequence.

Return customer(s) whose has last name begins with letters from M to Z only.

e. Write a query that returns the columns ProductName, UnitPrice, DateAdded from the Products
table. Return the row(s) with a unit price that’s greater than 500 and less than 2000 only. Sort the
result set in descending sequence by the DateAdded column.

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 5/6


Training Test SQL Essential Issue/Revision: 1/1

f. Write a query that returns customer information (includes CustomerId, FirstName, LastName,
Email, and Address) and total amount of all orders belong to that customer.

To calculate amount:

- Total amount for OrderItem = (Quantity * UnitPrice)*(1-DiscountPercent/100)

- Total amount for Order = Sum of all OrderItems’s Amount

-- THE END --

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 6/6

You might also like