0% found this document useful (0 votes)
1 views

SQL_query_assigment

The document outlines a final assignment for a database course focused on a Tech company's employee database consisting of three tables: EmployeeInformation, EmployeeSalary, and Departments. It details the structure of each table, the required SQL queries for creating and populating the database, and the assignment submission guidelines. Additionally, it includes a list of specific SQL queries to be executed and captured as part of the assignment answers.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

SQL_query_assigment

The document outlines a final assignment for a database course focused on a Tech company's employee database consisting of three tables: EmployeeInformation, EmployeeSalary, and Departments. It details the structure of each table, the required SQL queries for creating and populating the database, and the assignment submission guidelines. Additionally, it includes a list of specific SQL queries to be executed and captured as part of the assignment answers.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Introduction to database

Final assignment
Assignment description
In this assignment, we are going to work on a database of a Tech company. The database consists of
three tables:

 Table EmployeeInformation: contains personal information of all employees in the company.


o EmpID: employee identity. This identity is uniquely assigned to each employee.
o FirstName: first name of an employee.
o LastName: last name of an employee.
o Country: country where an employee comes from.
o PhoneNumber: phone number of an employee.
o DeptID: department identity to which an employee belongs. This DeptID refers to the
information described in the Departments table.
 Table EmployeeSalary: contains information regarding monthly salary and monthly bonus of
employees.
o EmpID: employee identity which refers to the information indicated in the
EmployeeInformation table.
o Salary: monthly base salary of an employee.
o Bonus: monthly bonus of an employee. If this field is empty, the bonus is zero.
 Table Departments: contains information about all departments in the company.
o DeptID: department identity. This identity is uniquely assigned to each department.
o DeptName: name of a department.
o DeptCode: code of a department.

Data records are filled in the tables as follows.

EmpID FirstName LastName Country PhoneNumber DeptID


101 Lauren Gates UK +44 7115 332978 D02
102 Johnathan Howard US +1 202-918-2132 D01
103 Alanna Barton AUS +61 483 362 313 D01
104 Rosalind Petty UK +44 7911 237286 D04
105 Louisa Richmond UK +44 7700 095135 D03
106 Harry Reilly AUS +61 479 144 417 D02
107 Amina Patel US +1 202-416-7962 D01
108 Rio Cooper UK +44 7457 490430 D05
109 Zac Avila AUS +61 435 448 902 D04
110 Kacie Bates UK +44 7700 059060 D05
Table: EmployeeInformation
EmpID Salary Bonus
101 10000 1000
102 60000 3000
103 45000 2000
104 19000 1000
105 34000 1500
106 48000 1200
107 15000
108 29000
109 42000
110 50000 3400
Table: EmployeeSalary

DeptID DeptName DeptCode


D01 Business Development BD
D02 Human Resources HR
D03 Quality Control QC
D04 Software Engineering SE
D05 Firmware Engineering FE
Table: Departments

Assignment requirements
Your task is to carefully read the database description, understand the meaning of all table columns and
how they relate to each other. There are steps that you will take:

 Install PostgreSQL (PostgreSQL: Downloads), and pgAdmin (Download (pgadmin.org) which is a


GUI to manage and execute queries in PostgreSQL.
 Use the installed pgAdmin to write, execute SQL queries and answer questions by taking full
screen captures visibly demonstrating the SQL queries and execution results. Here is an example
of a valid full screen capture:
Assignment submission
The submission file is a Word document (*.doc or *.docx) containing visual answers to the assignment
questions. The file is named as:

KHTN-MS-DB-K30-K31-StudentID.docx

For example, if your student ID is 20C12345, the file name is:

KHTN-MS-DB-K30-K31-20C12345.docx

The submission is then made via the form https://forms.gle/Tro2dumFoomqS2Ph8

Assignment deadline
Deadline for the submission is 23:59:59 26/07/2023.

Assignment questions
1. Write an SQL query to create a database with a name of your choice to store data of the Tech
company.
2. Write an SQL query to create the table EmployeeInformation. You have to decide attributes of
columns, primary key and foreign key if necessary.
3. Write an SQL query to create the table EmployeeSalary. You have to decide attributes of
columns, primary key and foreign key if necessary.
4. Write an SQL query to create the table Departments. You have to decide attributes of columns,
primary key and foreign key if necessary.
5. Write an SQL query to insert data records to the table EmployeeInformation as described above.
6. Write an SQL query to insert data records to the table EmployeeSalary as described above.
7. Write an SQL query to insert data records to the table Departments as described above.
8. Write an SQL query to list first names, last names, and phone numbers of employees from the
UK.
9. Write an SQL query to select all the employees who come from either US or AUS and have a
monthly salary at least (greater than or equal to) 10,000.
10. Write an SQL query to count the number of employees in each department.
11. Write an SQL query to calculate the annual employee cost (total base salary and bonus) of the
company.
12. Write an SQL query to select the top-5 employees having highest annual income and sort their
incomes in descending order.
13. Write an SQL query to select employees having the highest monthly income of each department.
14. Write an SQL query to show the total annual base salary of Software Engineering department.
15. Write an SQL query to select the employee having lowest annual income and his or her name
must contain the letter ‘n’.
16. Write an SQL query to show the monthly employee cost of all departments in descending order.
17. Write an SQL query to show the average monthly cost of employees of each country.
18. Write an SQL query to show employee counts, grouped by department and country.
19. Write an SQL query to display employee information of those who have the highest salary from
each country.
20. Write an SQL query to select all employees coming from countries whose names end with letter
‘s’ and sort their salary in ascending order.

Assignment answers
Paste your full-screen-capture answers here.

1. Write an SQL query to create a database with a name of your choice to store data of the Tech
company.
full-screen-capture 1.jpg
2. Write an SQL query to create the table EmployeeInformation. You have to decide attributes of
columns, primary key and foreign key if necessary.
full-screen-capture 2.jpg

3. Write an SQL query to create the table EmployeeSalary. You have to decide attributes of
columns, primary key and foreign key if necessary.
full-screen-capture 3.jpg
4. Write an SQL query to create the table Departments. You have to decide attributes of columns,
primary key and foreign key if necessary.
full-screen-capture 4.jpg

5. Write an SQL query to insert data records to the table EmployeeInformation as described above.
full-screen-capture 5.jpg
6. Write an SQL query to insert data records to the table EmployeeSalary as described above.
full-screen-capture 6.jpg

7. Write an SQL query to insert data records to the table Departments as described above.
full-screen-capture 7.jpg
8. Write an SQL query to list first names, last names, and phone numbers of employees from the
UK.
full-screen-capture 8.jpg

9. Write an SQL query to select all the employees who come from either US or AUS and have a
monthly salary at least (greater than or equal to) 10,000.
full-screen-capture 9.jpg
10. Write an SQL query to count the number of employees in each department.
full-screen-capture 10.jpg

11. Write an SQL query to calculate the annual employee cost (total base salary and bonus) of the
company.
full-screen-capture 11.jpg
12. Write an SQL query to select the top-5 employees having highest annual income and sort their
incomes in descending order.
full-screen-capture 12.jpg

13. Write an SQL query to select employees having the highest monthly income of each department.
full-screen-capture 13.jpg

14. Write an SQL query to show the total annual base salary of Software Engineering department.
full-screen-capture 14.jpg
15. Write an SQL query to select the employee having lowest annual income and his or her name
must contain the letter ‘n’.
full-screen-capture 15.jpg
16. Write an SQL query to show the monthly employee cost of all departments in descending order.
full-screen-capture 16.jpg

17. Write an SQL query to show the average monthly cost of employees of each country.
full-screen-capture 17.jpg
18. Write an SQL query to show employee counts, grouped by department and country.
full-screen-capture 18.jpg

19. Write an SQL query to display employee information of those who have the highest salary from
each country.
full-screen-capture 19.jpg

20. Write an SQL query to select all employees coming from countries whose names end with letter
‘s’ and sort their salary in ascending order.
full-screen-capture 20.jpg

You might also like