Sei sulla pagina 1di 11

Practical Workbook

Database Management Systems

Name : Year
: Batch :
Roll No :
Department:

Department of Computer Science & Information Technology


NED University of Engineering & Technology,
Karachi – 75270, Pakistan
INTRODUCTION
The course Database Management Systems, taught in SCIT (Department of Compute
Science & Information Technology), intends to teach the basic concepts as well as advanced
techniques in the management of databases of an organization.

The creation and manipulation of database objects requires programming in Structured Query
Language (SQL). SQL is a nonprocedural language with capabilities of creating and
manipulating data in tables and views. SQL is referred to as a query language because it has wide
range of facilities to retrieve data from a database. SQL may also be used to implement security
controls in a database system by assigning privileges to database users over database objects.
.

This workbook comprehensively covers programming in SQL as well as PL/SQL. This fourth
edition covers more features of SQL programming including joining operations and compound
queries. The examples and command variations has been increased. A new lab session covering
the generation of readable output using SQL*Plus tool of Oracle has been added. More exercises
have been included to give students the chance to improve their skills in SQL programming.

Twelve lab sessions cover SQL programming focusing on relational database concepts, retrieval
operations, Data Manipulation Language, Data Definition Language & Data Control Language.

*****
CONTENTS

Lab Session No. Object Signature

1 Create any scenario using Microsoft Excel theory: refers to what


has been seen in class.
2 Writing basic SQL Statement

3 Data Restricting and Sorting Data in SQL

4 Single-row and multiple-row functions in SQL

5 Displaying Data from Multiple Tables

6 Aggregating Data Using Group Functions and sub queries

7 Design ERD using ERD Plus theory: refers to what has been
seen in class.
8 Data manipulation operations in SQL

9 Creating and managing tables

10 Creating and manage constraints

11 Create and manage views.


12 Create and manage other database object
Practical NO:-1

Theory: refers to what has been seen in class.

Using any practical scenario in excel sheet and apply 10 formulae on it .Plot different graph according to
the scenario.
Practical NO:-2

Select statement Theory: refers to what has been seen in class.

Q1:-The following SELECT statement executes successfully:


SELECT last_name, job_id, salary AS Sal FROM employees;
A:-

Q2:-Show the structure of the DEPARTMENTS table. Select all data from the DEPARTMENTS table
A:-
.

Q3:-Show the structure of the EMPLOYEES table. Create a query to display the last name, job code,
hire date, and employee number for each employee, with employee number appearing first.
A:-

Q4:-Create a query to display unique job codes from the EMPLOYEES table Display the last name
concatenated with the job ID, separated by a comma and space, and name the column Employee
and Title.
A:-

Q5:-Create a query to display all the data from the EMPLOYEES table. Separate each column by a
comma. Name the column THE_OUTPUT.
A:-

Q6:-Create a query to display unique job codes from the EMPLOYEES table.
A:-
Practical No: - 3

Theory: refers to what has been seen in class.

Q1. Create a query to display the last name and salary of employees earning more than $12,000.
A:-

Q1.Q2. Create a query to display the employee last name and department number for employee
number 176.
A:-

Q3. Display the last name and salary for all employees whose salary is not in the range of $5,000
and $12,000.
A:-

Q4. Display the employee last name, job ID, and start date of employees hired between February
20, 1998, and May 1, 1998. Order the query in ascending order by start date.Display the last name
and department number of all employees in departments 20 and 50 in alphabetical order by name.
A:-

Q5. List the last name and salary of employees who earn between $5,000 and $12,000, and are in
department 20 or 50. Label the columns Employee and Monthly Salary, respectively.
A:-

Q6. Display the last name and hire date of every employee who was hired in 1994.
A:-

Q7. Display the last name and job title of all employees who do not have a manager.
A:-

Q8. Display the last name, salary, and commission for all employees who earn commissions. Sort
data in descending order of salary and commissions.
A:-
Practical No: - 4

Theory: refers to what has been seen in class.

Q1. Write a query to display the current date. Label the column Date.
A:-

Q 2. For each employee, display the employee number, last_name, salary, and salary
increased by 15% and expressed as a whole number.
A:-

Q3. Write a query that displays the employee’s last names with the first letter capitalized
and all other letters lowercase and the length of the name for all employees whose
name starts with J, A, or M. Give each column an appropriate label. Sort the results by
the employees’ last names. For each employee, display the employee’s last name, and
calculate the number of months between today and the date the employee was hired.
Label the column MONTHS_WORKED. Order your results by the number of months
employed. Round the number of months up to the closest whole number.
Note: Your results will differ.
A:-

Q4. Create a query to display the last name and salary for all employees. Format the
salary to be 15 characters long, left-padded with $. Label the column SALARY.
A:-

Q5. Display each employee’s last name, hire date, and salary review date, which is the
first Monday after six months of service. Label the column REVIEW. Format the dates to
appear in the format similar to “Monday, the Thirty-First of July, 2000.”
A:-
Q6.. Display the last name, hire date, and day of the week on which the employee
started. Label the column DAY. Order the results by the day of the week starting with
Monday. Create a query that displays the employees’ last names and commission
amounts. If an employee does not earn commission, put “No Commission.” Label the
column COMM.
A:-

Q7. Create a query that displays the employees’ last names and indicates the amounts
of their annual salaries with asterisks. Each asterisk signifies a thousand dollars. Sort
the data in descending order of salary. Label the column
EMPLOYEES_AND_THEIR_SALARIES.
A:-
Practical No: - 5

Theory: refers to what has been seen in class.

Q1. Write a query to display the last name, department number, and department name for all
employees.
A:-

Q 2. Create a unique listing of all jobs that are in department 30. Include the location of department
90 in the output.
A:-

Q 3. Write a query to display the employee last name, department name, location ID, and city of all
employees who earn a commission.
A:-

Q 4:-.Display the employee last name and department name for all employees who have an a
(lowercase) in their last names..
A:-

Q 5:- Write a query to display the last name, job, department number, and department name for all
employees who work in Toronto.
A:-

Q 6:-Display the employee last name and employee number along with their manager’s last name
and manager number. Label the columns Employee, Emp#, Manager, and Mgr#, respectively.
A:-

Q 7:-To display all employees including King, who has no manager.


A:-
Practical No: - 6

Theory: refers to what has been seen in class.

Q1. Group functions work across many rows to produce one result.
A:-

Q2.Display the highest, lowest, sum, and average salary of all employees. Label the
columns Maximum, Minimum, Sum, and Average, respectively. Round your results to
the nearest whole number..
A:-

Q3. Group functions include nulls in calculations.


A:-

Q4. Write a query to display the number of people with the same job.
A:-

Q5. Write a query that displays the difference between the highest and lowest salaries.
Label the column DIFFERENCE.
A:-

Q6. Display the manager number and the salary of the lowest paid employee for that
manager. Exclude anyone whose manager is not known. Exclude any groups where the
minimum salary is less than $6,000. Sort the output in descending order of salary.
A:-
Practical No: - 7

Theory: refers to what has been seen in class

Design ERD using ERD Plus.

Potrebbero piacerti anche