You are on page 1of 2

Practical Project (Database)

Table Creation Questions

1. Table Creation
Create a new table called "Employees" with the following fields:
 EmployeeID ( Primary Key) :[Example : EMP125,EMP147]
 FirstName ( 50 characters) :Set the "Validation Rule" property to require that it's not
empty.
 LastName ( 50 characters)
 Department ( 30 characters) [Production, Administration, Design]
 HireDate (Date/Time : Use Date/Time and set a validation rule to ensure it falls
between 2016 and 2023.

Set appropriate field properties such as field size and format

Insert the given below records into the table:


EmployeeID FirstName LastName Department HireDate
EMP001 John Doe Production 2017-03-15
EMP002 Jane Smith Administration 2018-06-22
EMP003 David Johnson Production 2019-01-10
EMP004 Sarah Wilson Design 2017-09-05
EMP005 Michael Brown Production 2020-02-18
EMP006 Emily Lee Administration 2016-11-30
EMP007 Robert Clark Design 2019-08-12
EMP008 Olivia Miller Production 2018-04-03
EMP009 William Taylor Production 2022-05-09
EMP010 Sophia Anderson Design 2021-07-14

2. Data Types and Field Properties:

Create a table named "Payroll" with the fields:


 PayrollID (Primary Key): Set as AutoNumber.
 EmployeeID (Foreign Key)
 Basic Pay :You can use the Currency data type.
 No. of Overtime(in hours) : Use Number with Field Size set to Double, and format it with
two decimal places.
 IsCurrentEmployee (Yes/No).
 Deductions (Currency): To track any deductions from the salary.
 Bonuses (Currency): To track any additional bonuses.
 Tax (Currency): To track taxes.

Insert the given below records into the table:


PayrollID EmployeeID Basic Pay OT IsCurrent Deduction Bonuses Tax
Employee
1 EMP001 50000.00 5.25 Yes 1500.00 2000.00 7500.00
2 EMP002 60000.00 3.75 Yes 1200.00 1800.00 9000.00
3 EMP003 5000.00 1.50 Yes 1300.00 2200.00 0.00
4 EMP004 62000.00 6.00 No 1400.00 1900.00 8500.00
5 EMP005 53000.00 4.25 Yes 1600.00 2100.00 7800.00
1
6 EMP006 58000.00 5.50 No 1400.00 1700.00 9200.00
7 EMP007 57000.00 3.00 Yes 1200.00 2300.00 8300.00
8 EMP008 51000.00 1.75 Yes 1500.00 1900.00 7900.00
9 EMP009 59000.00 5.25 Yes 1600.00 2200.00 8400.00
10 EMP010 63000.00 6.50 Yes 1700.00 2000.00 8700.00
Set appropriate field properties such as field size and format.

3. Suggest right data types, validation checks, and validation rules for given field in the above
table by considering the conditions. Try to give different validation check for each field by
observing the field values.

4. Table Relationships:
Create two tables, "Customers" and "Orders." Establish a one-to-many relationship between
them, ensuring that each order is associated with a single customer. Define the necessary
foreign keys and enforce referential integrity.

5. Write SQL statement for the following questions and write the output
i) To display a list of all employees name along with their department and hire date.
ii) To display the first and last names of all employees only in the "Production"
department.
iii) To display the employee’s First name, Last name and Hire date with the earliest hire
date.
iv) To display the employee’s First name, Last name and Hire date, where hired in
2020 or later.
v) Count the total number of employees hired in Design department.
vi) List all employees ID only who have not been assigned to a administrator
department.
vii) List employees name and department who are hired between 2016 and 2023.
viii) Calculate the total basic pay for all employees.
ix) Calculate the Net salary of each employee (Basic Pay + Bonuses - Deductions).
x) List employees ID only who are not current employees and had overtime hours.
xi) Calculate the average tax amount deducted from employee salaries.
xii) Display Employee ID, Payroll ID of employee who worked for more than 5 hours.
xiii) Display Employee ID of all current employees in descending order by their Basic
Pay.
xiv) Display Employee id, basic pay, Bonuses, dedication and net salary of all employee
who are tax payer.
xv) Display Employee id and pay roll id only whose overtime is below 2 hours or not pay
any tax.

You might also like