Assignment File2
Assignment File2
ICT - 251
B. TECH.
IN
SUBMITTED TO SUBMITTED BY
NOVEMBER 2023
Assignment 1
Case Study 1
A sports centre aims to set up a database to maintain the following information. The database stores the
name, the address and a unique ID of each employee. The employees are classified into three categories:
trainers, receptionists and administrators. Each trainer has one or more specialities (e.g., swimming, tennis,
squash etc). Each receptionist can be reached through a landline phone number. Each receptionist must be
supervised by one administrator and an administrator may supervise multiple receptionists. Each member
of this sports centre is identified by their membership id and the database also stores their names and
emails. Each week a trainer may offer regular training classes that members can participate in. Each
training class should focus on one of the specialities of the corresponding trainer and must have a class
size of no more than 10. Each training class from a trainer is referred by the day of the week (i.e., Monday,
Tuesday, ...) because each trainer offers at most one training class per day. After a member participates in
a training class, the member may submit feedback to a receptionist and the feedback contains a rating from
1 (very unsatisfied) to 5 (very satisfied), a date and a detailed description.
Draw an Entity Relationship (ER) diagram for the above database, which should include entities,
relationships, attributes and constraints wherever appropriate (you can make more assumptions if
necessary).
Page 1
Case Study 2
A company database needs to store information about employees (identified by employee_id, with salary
and phone_no as attributes); departments (identified by department_no, with department_name and budget
as attributes); and dependent children of employees (with name and age as attributes). Employees work in
departments (i.e. an employee can work in more than one department); each department is managed by an
employee; a child must be identified uniquely by name when the parent (who is an employee; you can
assume that only one parent works for the company) is known. We are not interested in information about a
child once the parent leaves the company.
Draw an ER diagram using the Chen notation for this database. Indicate the cardinality mappings in the ER
diagram.
Page 2
Assignment 2
Department Table
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
Employee Table
Salary Grade
1 700.00 1200.00
2 1201.00 1400.00
3 1401.00 2000.00
4 2001.00 3000.00
5 3001.00 9999.00
Page 3
1. Create department, employee and salary grade tables.
Page 4
3. Insert the given data in the tables.
Page 5
4. Display the details of all employees.
Page 6
6. Display employee name, job title and salary of all employees.
Page 7
8. Display details of all employees working as managers.
Page 8
10. Display numbers of all departments where employees are working.
Page 9
12. Display details of all employees whose salary range is 1000 to 2000.
13. Display details of all employees who are not working in departments 10 and 30.
Page 10
14. Display the names and job titles of all employees whose salary is either 1000, 3000 or 5000.
15. Display employee id, salary and job title of all employees of department 20.
Page 11
16. Display employee id and name of those employees who do not earn commission.
17. Display details of all employees who were hired before 1st January 1989.
Page 12
Assignment 3
2. Display employee id and employee name, who do not earn commission and are not clerks.
Page 13
3. Display details of all employees who were hired in the year 1981.
Page 14
5. Display minimum and maximum salaries in the organization.
Page 15
7. Total number of employees who are not entitled to commission.
Page 16
9. Display employee id and employee name of all employees whose name starts with the letter 'J' and
ends with 'S' and were hired before 1st January 1982.
10. Display the employee id and department no of all employee who are earning more than 2500 and
whose name has third letter 'N' and working in department 10.
Page 17
11. Create a query to display all the data from the employees table. Separate each column by a comma.
Name the column 'The Output'.
12. Display the employee name concatenated with the job, separated by a comma and space, and name
the column 'Employee and Title'.
13. Display the employee if an employee is president or a sales representative, and if the employee earns
more than $15000 annually.
Page 18
14. Display the names and salaries of all employees. Order the result by department no, and then in
descending order by salary.
Page 19
15. Display the name, salary and commission for all employees who earn a commission. Sort data in
descending order of salary and commissions.
16. Display the names of all employees who have an a and an e in their name.
Page 20
17. Display the name, job, and salary for all employees whose job is sales representative or clerk and
whose salary is not equal to 2500, 3500 or 7000.
18. Display the average salary of departments that have an average salary greater than 2000.
Page 21
19. Display the job and total monthly salary for each job with a total payroll exceeding 5000. Exclude sales
representatives and sort the list by the total monthly salary.
Page 22
Assignment 4
1. Modify the structure of the employees table to have a primary key constraint on the filed employee id.
2. Modify the structure of the orders table to have foreign key constraint on the field employee id.
Page 23
3. Write a query to select the vendor id, name and phone number of the vendor who lives in the state of
Uttar Pradesh.
4. Write a query to select the name and address of the vendor whose name contains the letter 'a'.
Page 24
5. Write a query to count the number of vendors who fall in the state of 'Uttar Pradesh' If the number of
vendors in the state of Uttar Pradesh is x, the result should be as 'Number of vendors in Uttar Pradesh
is x'.
6. Write a query to select the vendor id, name and state of the vendor whose address 2 field has a '.' in it.
Page 25
7. Write a query to list the details of vendors who do not belong to the states of 'Uttar Pradesh' and
'Rajasthan'.
8. Write a query to list the material id, its name and stock available for those whose unit price falls above
600 but less than 900.
Page 26
9. Write a query to display the information of a material whose unit price is either 450.25, 500, 700 or 900.
10. Write a query to display the information about the material whose stock is less than 5.
Page 27
11. Write a query to change the address 1 of the vendor to '186, Circular No. 2' whose vendor id is
'V00001'.
12. Modify the date of birth to 23 August 1967 where employee id E10120.
Page 28
13. Write a query to inform you about the vendors in the following format: Vendor with id V00001 lives in the
state of Delhi.
14. Write a query to display the names of all employees whose commission is more than 10% of their basic
salary and falls in the category of 'Salesman'.
Page 29
15. Write a query to select the minimum, maximum and average salary of the employees working in the
organization. The headings should be 'smin', 'smax' and 'savg' respectively.
16. Write a query to display the employee id, name and department no. of all employees who are either
working as salesman or other staff. The grouping should be department-wise. Within the department, it
should have all salesmen together and all other staff together.
Page 30
17. Write a query to inform you about the no. of employees working for each department.
18. Write a query to select the name, department name and location of employees who are designated as
managers.
Page 31
Assignment 5
1. Write a query to select the employee id and name of those employees who earn a salary more than the
average salary of all the employees working in the organization.
2. Write a query to display the name, designation, department name and location who do not work in the
Noida office.
Page 32
3. Write a query to list the id and name of all employees in alphabetical order of their name.
4. Write a query to select the name and date of birth of those employees who were born before February
7, 1976.
Page 33
5. Write a query to select the name and basic salary of employees who have the letter 'E' or 'S' in their
names. Further, modify the query list for those who do not contain 'M' in their names.
6. Write a query to select the name and department of those employees who have age between 20 and 30
years.
Page 34
7. Write a query to list the id, name and department no. of employees who were born in the month of
February.
Page 35