Lab Exercises: Exercise 1
Lab Exercises: Exercise 1
Chapter1
Exercise 1
You have been appointed as the database administrator at the Smith’s Department Store, for
its new store in New York. You need to create a table named Customer_details, for the new
store of Smith’s Departmental store. The fields of the table, Customer_details are:
As a database administrator, you need to add the Telephone field to the Customer_details
table, so that you can specify the phone number of the customers. The size of the
telephone field is 10 digits.
Exercise 3
While specifying the details of the customers in the Customer_details table, you find that the
size of some of the addresses is more than the size specified for the Customer_Address field.
As a result, you need to alter the table, Customer_details so that the addresses of large sizes
can be stored in the table.
Chapter2
Exercise 1
You have appointed, Steve as the junior database administrator, for the new store at New
York. Steve wants to view the records of the customers that have visited the store. In
addition, Steve wants to view only distinct records of the Customer_details table.
Exercise 2
Steve also wants to view the records of those customers who have a membership of the store.
In addition, you have also created an Employee_details table that contains the details of all
the employees of the New York store. The Employee_details table contains the fields, which
are Emp_id, Emp_Fname, Emp_Lname, Emp_designation, Dept_ID, Emp_Salary, and
Emp_Bonus.
The employees of the Sales department, whose Dept_ID is 10, have been given a bonus of
$500. However, before, you update their salary field, you want to view the records of those
employees who are working in the Sales department.
Exercise 3
You have been asked to provide a list of all those employees whose salary is more than or
equal to 3000. In addition, you also have been asked to provide the details of all those
employees whose employee ID is 1023, 1034, 1056, and 1098.
Exercise 4
The management of the store has asked you to provide the details of all those employees who
are not working in the Marketing department, whose Dept_ID is 20. In addition, you have also
been asked to provide the details of the customers, whose annual income is more than 200000
and they do not have the membership of the store.
Chapter3
Exercise 1
You have asked Steve to calculate the average salary of the employees of the New York store.
In addition, you also need to know the total number of employees in the New York store.
Exercise 2
You have been asked to provide the details of all those employees of the New York store, who
receive the maximum salary.
Exercise 3
You have been asked by the management to provide the average salaries for each
department of the New York store. In addition, you also need top provide the details of those
employees who receive salary more than 4000.
Chapter4
Exercise 1
You have created a table named Department. The fields of this table are:
This table contains the department name and the ID that is assigned to each department of
the store. In addition, this table lists the total number of employees in each department. You
want to view the details of the employees along with the name of the department in which
each employee works.
Exercise 2
The store has recruited 50 new employees. The junior system administrator, Steve has
entered the details of the new employees in the Employee_details table and updated the
Department table. However, only some of the newly appointed employees have been
assigned different departments. You need to view the records of all the employees,
including the record of employees who have been assigned a department and employees who
have not been assigned a department.
Chapter5
Exercise 1
You have been asked by the HR manager to create the two tables, which are:
You need to insert the records from the Customer_details table to any one of the given tables,
on the basis of the membership field of the Customer_details table. If the customer has a
membership of the store, then the record has to be inserted in table, Cust_Details1. In case,
the specified customer does not have the membership of the store, the record has to be
inserted in the table, Cust_Details2.
Exercise 2
One of the employees, Nancy Jackson, has been transferred from the Administration
department to the Customer Care department. In addition, the employee ID of Nancy
Jackson has been changed from 2340 to 2330. You need to update the Employee_details
table to make these changes for the record of Nancy Jackson.
Chapter 6
Exercise 1
As a database administrator, you have been asked to list the details of the employees,
working in the New York store, whose first name starts with either A, D, and S. In
addition, this list should not contain duplicate values.
You have also been asked to list the details of the employees of the New York store,
whose first name starts with D and work in the Administration department.
Exercise 2
As a database administrator, you have been asked to list the details of all the customers,
except those customers who do not have a membership in the New York store. Similarly, you
need to provide the details of all the employees except those employees who work in the
Accounting department.
Exercise 3
For appropriate identification of the employees on the basis of their designation, you have
been asked to assign, ‘Top Management’ to those employees whose designation is
Manager. Similarly, you need to assign, ‘Operational Management’ to those employees whose
designation is either Associate or Clerk.
Similarly, you have been asked to provide the details of the employees of the New York store,
on the basis of the given salary status:
Chapter 7
Exercise 1
You need to secure the data stored in various tables, such as the Customer_details and the
Employee_details. As a result, you have decided to create views based on these tables. These
views are:
Cust_View1: This view is based on the Customer_details table, and contains the
fields, Customer_ID, Customer_Fname, Customer_Lname, and Customer_Address.
Emp_View1: This view is based on the Employee_details table, and contains the
fields, Emp_ID, Emp_Fname, Emp_Lname, Dept_ID, Emp_Bonus, and Emp_Salary.
Exercise 2
Since the data contained in the view, Cust_View1 is important, you have decided to
create this view as a Read-only view. In addition, you need to modify the Emp_View1 to
include the field, Emp_designation and remove the field, Emp_Bonus.
You need to modify the Employee_details table to include the field, Emp_Address. As a result,
the view based on the Employee_details table becomes invalid. You need to recompile
the invalid view to make it a valid view.
Exercise 3
You have asked your assistant database administrator, Steve, to provide the list of those
customers, whose Customer ID is between 000025 and 000148. However, Steve does not
have the rights to access the Customer_details and the Employee_details tables.
Similarly, you have asked Steve to provide the details of all those employees, whose
salary is greater than or equal to 15,000. In addition to this, you have asked Steve to
provide the sum of the salary of those employees, whose salary is less than 6000.
Chapter 8
Exercise 1
As a database administrator, you need to generate a sequence for all the rows of the
Employee table. However, after updating the Employee table, you realize that the
Employee table has been incorrectly updated. As a result, you rollback the current
transaction. After you rollback the transaction and you need to regenerate the sequence.
Exercise 2
You have been asked by the HR department to provide the details of those employees
whose designation is either Manager or Executive and salary of that employee is between
12000 and 14500.
Chapter 9
Exercise 1
As a database administrator, you need to ensure the validity of the users accessing the
various tables of the database. As a result, you plan to create the user accounts for all
those employees whose designation is Manager. In addition, while creating these user
accounts, you need to assign tablespace to all these newly created user accounts. The
name of the tablespaces starts from Manager1.
Exercise 2
Along with1 creating user accounts, you need to create two roles, which are:
Accounts, which will be assigned to all the employees of the accounting and the
finance departments.