You are on page 1of 2

NOVAON DIGITAL GROUP

Head Office : Singapore Office:


Add : Fl 09, Cong doan Ngan hang VN Building, Duy Tan, Hanoi, Vietnam Add : 5001 Beach Road, Golden Mile Complex, #08-10, Singapore 199588
Tel : (+84) 2422 31 9999 Tel : (+65) 6248 48 15

Database/SQL TEST PRACTISE


Times: 60 minutes

Barem: Each Item from 1 and 5: 2


You work as a Database Developer for a Global mart. The mart uses RDBMS for project management.
The fragments of database schema are given in figure below.

1. Create a database called AdvancedTech_SQL_FinalTest and run below script to create database
schema (or run AdvancedTech_SQL_FinalTest_Script.sql file in the same order with this
documentation).

Then write a script:


- Insert 4 records for Department: 'Customer Service', 'Electronics', 'Hardware', 'Sporting Goods'
- Insert 4 records for Title: 'CEO', 'Store Manager', 'Department Manager', 'Sales Associate'
- Insert at least 5 records for Employee, Timesheet, Vendor tables.

2. Write a stored procedure named SP_InsertOrUpdateEmployee with parameters:


- EmployeeID
- SSN
- FirstName
- LastName
- JobTitleID
- DepartmentID
- BirthDate
- HireDate
- HourlyWage
- SupervisorID

NOVAON DIGITAL GROUP


W ebs i t e: n ova on . as i a | Ho tl i n e: 093 9 378 6 86 | E mai l : co n ta ct @ nov ao n. a s i a
NOVAON DIGITAL GROUP
Head Office : Singapore Office:
Add : Fl 09, Cong doan Ngan hang VN Building, Duy Tan, Hanoi, Vietnam Add : 5001 Beach Road, Golden Mile Complex, #08-10, Singapore 199588
Tel : (+84) 2422 31 9999 Tel : (+65) 6248 48 15

Fulfills:
- If there is a record in dbo.Employee table which match with EmployeeID parameter then update
that record with the parameters.
- If EmployeeID parameter doesn't exists in dbo.Employee table, insert a new record with
parameters.

3. Write an SQL stored procedure called SP_DeactivateProduct which given a product Id that is
currently active, will deactivate that product

4. Write:
- A SQL function that returns total hours worked for a specific employee.
- Then, write a SQL SELECT statement which display each employee's name, payrolldate, and
total hours worked using above function.

5. Write a trigger which prevents user inputs a date of birth later than current date or HourlyWage is
negative number.

NOVAON DIGITAL GROUP


W ebs i t e: n ova on . as i a | Ho tl i n e: 093 9 378 6 86 | E mai l : co n ta ct @ nov ao n. a s i a

You might also like