You are on page 1of 8

College of Informatics and Computing Sciences

Name: _SOBELINO, JAMES CARL A . _______________________________


Section: __IT 2102___________ Score: ____________

General Instructions:
● Read each statement carefully and write SQL statements for each item.
● Cheating and any form of academic dishonesty are NOT allowed, once caught doing such
will be automatically subjected to disciplinary actions and will receive a score of ZERO.

1. Create a database named YourSurname_Company. (2pts)

2. Create the following tables and set up the following fields.

●JobTbl (5pts)
ATTRIBUTE NAME DATA DECLARATION

JobCode Variable Character, Size=4, Primary Key

JobDescription Variable Character, Size=25

●EmployeeTbl (5pts)
ATTRIBUTE NAME DATA DECLARATION

EmpNumber Variable Character, Size=4, Primary Key

EmpLName Variable Character, Size=10


EmpFName Variable Character, Size=10

EmpHiredDate Date

JobCode Foreign Key related to JobTbl

●ProjectTbl (5pts)
ATTRIBUTE NAME DATA DECLARATION

ProjectNumber Variable Character, Size=4, Primary Key

ProjectName Variable Character, Size=20

ProjectValue Decimal(11,2)
EmpNumber Foreign Key related to EmployeeTbl

3. Input data for the following tables.


●JobTbl (5pts)

ANSWER
●EmployeeTbl (5pts)

●ProjectTbl (5pts)
College of Informatics and Computing Sciences

Perform the following SQL operations: (3pts each)


4. Retrieve all the data from each table.
5. Retrieve the records of the employee who works as a Database Designer.

6. Retrieve the records of the employee who works as a Database Administrator.

7. Find all the records of the employees that were hired before January 01, 2015.

8. Find all the records of the employees that were hired from January 01, 2016 to December
31, 2017.

9. Update the job description of J112 to Senior Architect.


10. Using a single SQL statement, retrieve all the records of the employees who work as System Analysts,
Programmer, and General Support.

11. Retrieve the records of the employee whose last name starts with ‘B’.

12. Retrieve the records of the employee whose first name ends with ‘N’.
13. Retrieve the records of the employee whose first name starts with ‘A’ and ends with ‘Y’.

14. Count how many employees work as Programmers.

15. Using an aggregate function, retrieve all the records of the most expensive project.

16. Add another column named ‘Department’ in the JobTbl. Decide the appropriate data type and field size.

17. Create a view based on the question in number 5. Name your view as DBDesigner.

18. Retrieve all the records of the view you created in number 17.

19. Using an aggregate function, compute the total value of the projects of employee E012.

20. Retrieve all the records from EmployeeTbl. Arrange the employee's first names in
alphabetical order.
21. Save all the changes made in your database. (2pts)

You might also like