0% found this document useful (0 votes)
159 views63 pages

20dce007 Practical1,2

The document discusses key concepts related to database management systems including file systems, DBMS, RDBMS, DDBMS, SQL, and PL/SQL. It provides definitions and features of each concept. It also includes examples of creating tables in Oracle and performing queries using SQL. The practical questions guide working with tables, inserting data, and retrieving data through queries.

Uploaded by

Anand Bapodara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
159 views63 pages

20dce007 Practical1,2

The document discusses key concepts related to database management systems including file systems, DBMS, RDBMS, DDBMS, SQL, and PL/SQL. It provides definitions and features of each concept. It also includes examples of creating tables in Oracle and performing queries using SQL. The practical questions guide working with tables, inserting data, and retrieving data through queries.

Uploaded by

Anand Bapodara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 63

CE246:DBMS 20DCE007

PRACTCAL-1
Aim:
File System:
 A File Management system is a DBMS that allows acces to single files or
tables at a time. In a File System, data is directly stored in set of files. It
contains flat files that have no relation to other files (when only one table
is stored in single file, then this file is known as flat file).
 It helps you to organizes the data and allows easy retrieval of files when
they are required. It mostly consists of different types of files like mp3,
mp4, txt, doc, etc. that are grouped into directories.

 A file system enables you to handle the way of reading and writing data
to the storage medium. It is directly installed into the computer with the
Operating systems such as Windows and

Features of a File system:


Here are important elements of the file system:

 It helps you to store data in a group of files.


 Files data are dependent on each other.
 C/C++ and COBOL languages were used to design the files.
 Shared File System Support
 Fast File System Recovery.

DBMS:
 A Database Management System (DBMS) is software designed to store,
retrieve, define, and manage data in a database.

Features of DBMS:
 A user-accessible catalog of data
 Transaction support
 Concurrency control with Recovery services
 Authorization services
 The value of data is the same at all places.
 Offers support for data communication

1|DEPSTAR-CE
CE246:DBMS 20DCE007

 Independent utility services


 Allows multiple users to share a file at the same time

 DBMS software primarily functions as an interface between the end user


and the database, simultaneously managing the data, the database engine,
and the database schema in order to facilitate the organization and
manipulation of data.
 Though functions of DBMS vary greatly, general-purpose DBMS
features and capabilities should include: a user accessible catalog
describing metadata, DBMS library management system, data abstraction
and independence, data security, logging and auditing of activity, support
for concurrency and transactions, support for authorization of access,
access support from remote locations, DBMS data recovery support in the
event of damage, and enforcement of constraints to ensure the data
follows certain rules.

RDBMS:
 A database management system (DBMS) that incorporates the relational-
data model, normally including a Structured Query Language (SQL)
application programming interface.
2|DEPSTAR-CE
CE246:DBMS 20DCE007

 It is a DBMS in which the database is organized and accessed according


to the relationships between data items. In a relational database,
relationships between data items are expressed by means of tables.
Interdependencies among these tables are expressed by data values rather
than by pointers. This allows a high degree of data independence.

DDBMS:

 A distributed database management system (DDBMS) is a set of


multiple, logically interrelated databases distributed over a network. They
provide a mechanism that makes the distribution of data transparent to
users.

 DDBMS is widely used in data warehousing, where huge volumes of data


are processed and accessed by numerous users or database clients at the
same time. This database system is used to manage data in networks,
maintain confidentiality and handle data integrity. A distributed database
management system is designed for heterogeneous database platforms
that focus on heterogeneous database management systems.

Difference between Filesystem vs. DBMS:

3|DEPSTAR-CE
CE246:DBMS 20DCE007

Difference between DBMS and RDBMS:

4|DEPSTAR-CE
CE246:DBMS 20DCE007

PRACTICAL-2

Aim: Introduction to Oracle (step by step installation, introduction of sql, plsql).


ORACLE:

 ORACLE is a fourth generation relational database management system. In general, a


database management system (DBMS) must be able to reliably manage a large
amount of data in a multi-user environment so that many users can concurrently
access the same data. All this must be accomplished while delivering high
performance to the users of the database. A DBMS must also be secure from
unauthorized access and provide efficient solutions for failure recovery. The
ORACLE Server provides efficient and effective solutions for the major database
features.

 ORACLE consists of many tools that allow you to create an application with ease and
flexibility. You must determine how to implement your requirements using the
features available in ORACLE, along with its tools. The features and tools that you
choose to use to implement your application can significantly affect the performance
of your application.

SQL:

 Structure Query Language(SQL) is a database query language used for storing and
managing data in Relational DBMS. SQL was the first commercial language
introduced for E.F Codd's Relational model of database. Today almost all
RDBMS(MySql, Oracle, Infomix, Sybase, MS Access) use SQL as the standard
database query language. SQL is used to perform all types of data operations in
RDBMS.

PLSQL:

 Oracle PL/SQL is an extension of SQL language that combines the data


manipulation power of SQL with the processing power of procedural language to
create super powerful SQL queries. PL/SQL ensures seamless processing of SQL
statements by enhancing the security, portability, and robustness of the Database.

 PL/SQL means instructing the compiler ‘what to do’ through SQL and ‘how to do’
through its procedural way. Similar to other database languages, it gives more control
to the programmers by the use of loops, conditions and object-oriented concepts. The
PL/SQL Full form is “Procedural Language extensions to SQL”.

5|DEPSTAR-CE
CE246:DBMS 20DCE007

PRACTICAL-3
AIM:To study DDL-create and DML-insert commands.
(i) Create tables according to the following definition.
● CREATE TABLE DEPOSIT (ACTNO VARCHAR2(5), CNAME VARCHAR2(18),
BNAME VARCHAR2(18), AMOUNT NUMBER (8,2), ADATE DATE);
● CREATE TABLE BRANCH (BNAME VARCHAR2(18), CITY VARCHAR2(18));
● CREATE TABLE CUSTOMERS (CNAME VARCHAR2(19), CITY VARCHAR2(18));
● CREATE TABLE BORROW (LOANNO VARCHAR2(5), CNAME VARCHAR2(18),
BNAME VARCHAR2(18), AMOUNT NUMBER (8,2));

6|DEPSTAR-CE
CE246:DBMS 20DCE007

Branch :

7|DEPSTAR-CE
CE246:DBMS 20DCE007

Customer Table:

BORROW TABLE:

8|DEPSTAR-CE
CE246:DBMS 20DCE007

Aim:From the above given tables perform the following queries:

9|DEPSTAR-CE
CE246:DBMS 20DCE007

(1)Describe deposit, branch.

2)Describe borrow, customers.

10 | D E P S T A R - C E
CE246:DBMS 20DCE007

11 | D E P S T A R - C E
CE246:DBMS 20DCE007

3) List all data from table DEPOSIT.

(4) List all data from table BORROW.

12 | D E P S T A R - C E
CE246:DBMS 20DCE007

(5) List all data from table CUSTOMERS.

(6) List all data from table BRANCH.

13 | D E P S T A R - C E
CE246:DBMS 20DCE007

(7) Give account no and amount of depositors.

(8) Give name of depositors having amount greater than 4000.

14 | D E P S T A R - C E
CE246:DBMS 20DCE007

(9) Give name of customers who opened account after date '1-12-96'.

(10) Give name of city where branch karolbagh is located.

15 | D E P S T A R - C E
CE246:DBMS 20DCE007

(11) Give account no and amount of customer having account opened


between date 1-12-96 and 1-6- 96.

(12) Give names of depositors having account at VRCE.

16 | D E P S T A R - C E
CE246:DBMS 20DCE007

PRACTICAL-4
Aim:Create the below given table and insert the data accordingly.

Queries:
(1)Create Table Job (job_id, job_title, min_sal, max_sal)

17 | D E P S T A R - C E
CE246:DBMS 20DCE007

(2)Create table Employee (emp_no, emp_name,emp_sal,emp_comm, dept_no, l_name,


dept_name,job_id, location, manager_id, hiredate)

(3)Create table deposit(a_no,cname,bname,amount,a_date)

18 | D E P S T A R - C E
CE246:DBMS 20DCE007

Aim:Perform following queries


Queries:
(1)Retrieve all data from employee, jobs and deposit.

19 | D E P S T A R - C E
CE246:DBMS 20DCE007

(2) Give details of account no. and deposited rupees of customers having
account opened between dates 01-01-06 and 25-07-06.

(3) Display all jobs with minimum salary is greater than 4000.
20 | D E P S T A R - C E
CE246:DBMS 20DCE007

(4) Display name and salary of employee whose department no is 20. Give
alias name to name of employee.

(5) Display employee no, name and department details of those employee
whose department lies in (10,20).

(6) Display the non-null values of employees.

21 | D E P S T A R - C E
CE246:DBMS 20DCE007

(7) Display name of customer along with its account no (both column
should be displayed as one) whose amount is not equal to 8000 Rs.

(8) Display the content of job details with minimum salary either 2000 or
4000.
22 | D E P S T A R - C E
CE246:DBMS 20DCE007

Aim:To study various options of LIKE predicate

23 | D E P S T A R - C E
CE246:DBMS 20DCE007

1)Display all employee whose name start with ‘A’ and third character is
‘‘a’.

(2) Display name, number and salary of those employees whose name is 5
characters long and first three characters are ‘Ani’.

(3) Display all information of employee whose second character of name is


either ‘M’ or ‘N’.

24 | D E P S T A R - C E
CE246:DBMS 20DCE007

(4) Find the list of all customer name whose branch is in ‘andheri’ or
‘dadar’ or ‘virar’

5) Display the job name whose first three character in job id field is ‘FI_’.

25 | D E P S T A R - C E
CE246:DBMS 20DCE007

(6) Display the title/name of job who’s last three character are ‘_MGR’ and
their maximum salary is greater than Rs 12000

7)Display the non-null values of employees and also employee name second
character should be ‘n’ and string should be 5-character long.

26 | D E P S T A R - C E
CE246:DBMS 20DCE007

8) Display the null values of employee and also employee name’s third
character should be ‘a’.

9) What will be output if you are giving LIKE predicate as ‘%\_%’


ESCAPE ‘\’

27 | D E P S T A R - C E
CE246:DBMS 20DCE007

PRACTICAL-5

28 | D E P S T A R - C E
CE246:DBMS 20DCE007

1)List total deposit from deposit.

2) List total loan from karolbagh branch

(3) Give maximum loan from branch vrce.

29 | D E P S T A R - C E
CE246:DBMS 20DCE007

(4) Count total number of customers

(5) Count total number of customer’s cities.

(6) Create table supplier from employee with all the columns.

(7) Create table sup1 from employee with first two columns.

30 | D E P S T A R - C E
CE246:DBMS 20DCE007

(8) Create table sup2 from employee with no data

(9) Insert the data into sup2 from employee whose second character should be ‘n’ and
string should be 5 characters long in employee name field.

(10) Delete all the rows from sup1.

31 | D E P S T A R - C E
CE246:DBMS 20DCE007

(11) Delete the detail of supplier whose sup_no is 103.

(12) Rename the table sup2

(13) Destroy table sup1 with all the data.

32 | D E P S T A R - C E
CE246:DBMS 20DCE007

(14) Update the value dept_no to 10 where second character of emp. name
is ‘m’.

(15) Update the value of employee name whose employee number is 103.

(16) Add one column phone to employee with size of column is 10.

33 | D E P S T A R - C E
CE246:DBMS 20DCE007

(17) Modify the column emp_name to hold maximum of 30 characters.

(18)Count the total no as well as distinct rows in dept_no column with a


condition of salary greater than 1000 of employee

(19) Display the detail of all employees in ascending order, descending


order of their name and no.

34 | D E P S T A R - C E
CE246:DBMS 20DCE007

(20) Display the dept_no in ascending order and accordingly display


emp_comm in descending order.

(21) Update the value of emp_comm to 500 where dept_no is 20.

(22) Display the emp_comm in ascending order with null value first and
accordingly sort employee salary in descending order.

35 | D E P S T A R - C E
CE246:DBMS 20DCE007

PRACTICAL-6
Aim:To study Single-row functions.

36 | D E P S T A R - C E
CE246:DBMS 20DCE007

(1)Write a query to display the current date. Label the column Date

(2) For each employee, display the employee number, salary, and salary
increased by 15% and expressed as a whole number. Label the column
New Salary

(3) Modify your query no (2) to add a column that subtracts the old salary
from the new salary. Label the column Increase

37 | D E P S T A R - C E
CE246:DBMS 20DCE007

(4) Write a query that displays the employee’s names with the first letter
capitalized and all other letters lowercase, and the length of the names, 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.

(5) Write a query that produces the following for each employee: earns
monthly

(6) Display the name, date, number of months employed and day of the
week on which the employee has started. Order the results by the day of
the week starting with Monday.
38 | D E P S T A R - C E
CE246:DBMS 20DCE007

PRACTICAL-7
AIM: Displaying data from Multiple Tables (join)

(1)Give details of customers ANIL.

39 | D E P S T A R - C E
CE246:DBMS 20DCE007

(2) Give name of customer who are borrowers and depositors and having
living city nagpur

(3) Give city as their city name of customers having same living branch.

40 | D E P S T A R - C E
CE246:DBMS 20DCE007

(4) Write a query to display the last name, department number, and
department name for all employees.

(5) Create a unique listing of all jobs that are in department 30. Include the
location of the department in the output

41 | D E P S T A R - C E
CE246:DBMS 20DCE007

(6) Write a query to display the employee name, department number, and
department name for all employees who work in NEW YORK.

(7) 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.

42 | D E P S T A R - C E
CE246:DBMS 20DCE007

(8) Create a query to display the name and hire date of any employee hired
after employee “smith

select emp_name,hiredate from employee where hiredate > (select hiredate from employee
where emp_name='smith');

PRACTICAL-8

AIM: To apply the concept of Aggregating Data using Group functions.

43 | D E P S T A R - C E
CE246:DBMS 20DCE007

(1) List total deposit of customer having account date after 1-jan-96.

(2) List total deposit of customers living in city Nagpur.

(3) List maximum deposit of customers living in bombay.

44 | D E P S T A R - C E
CE246:DBMS 20DCE007

(4) 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.

(5) Write a query that displays the difference between the highest and
lowest salaries. Label the column DIFFERENCE.

45 | D E P S T A R - C E
CE246:DBMS 20DCE007

(6) Create a query that will display the total number of employees and, of
that total, the number of employees hired in 1995, 1996, 1997, and 1998

(7) Find the average salaries for each department without displaying the
respective department numbers.

46 | D E P S T A R - C E
CE246:DBMS 20DCE007

(8) Write a query to display the total salary being paid to each job title,
within each department.

(9) Find the average salaries > 2000 for each department without
displaying the respective department numbers.

47 | D E P S T A R - C E
CE246:DBMS 20DCE007

(10) Display the job and total salary for each job with a total salary amount
exceeding 3000 and sorts the list by the total salary.

(11) List the branches having sum of deposit more than 5000 and located in
city bombay.

PRACTICAL-9

Aim: To solve queries using the concept of sub query

48 | D E P S T A R - C E
CE246:DBMS 20DCE007

Queries:

(1)Write a query to display the last name and hire date of any employee in
the same department as smith. Exclude smith

(2)Give name of customers who are depositors having same branch city of
mr. sunil.

(3) Give deposit details and loan details of customer in same city where
pramod is living.

49 | D E P S T A R - C E
CE246:DBMS 20DCE007

(4)Create a query to display the employee numbers and last names of all
employees who earn more than the average salary. Sort the results in
ascending order of salary.

(5) Give names of depositors having same living city as mr. anil and having
deposit amount greater than 2000.

(6) Display the last name and salary of every employee who reports to ford.

50 | D E P S T A R - C E
CE246:DBMS 20DCE007

(7) Display the department number, name, and job for every employee in
the Accounting department.

(8) List the name of branch having highest number of depositors.

(9) Give the name of cities where in which the maximum numbers of
branches are located.

51 | D E P S T A R - C E
CE246:DBMS 20DCE007

(10) Give name of customers living in same city where maximum depositors
are located.

Practical-10
Aim: Manipulating Data.

52 | D E P S T A R - C E
CE246:DBMS 20DCE007

Queries:
(1)Give 10% interest to all depositors.

(2) Give 10% interest to all depositors having branch vrce.

53 | D E P S T A R - C E
CE246:DBMS 20DCE007

(3) Give 10% interest to all depositors living in nagpur and having branch
city bombay.

(4) Write a query which changes the department number of all employees
with empno 7788’s job to employee 7844’current department number.

54 | D E P S T A R - C E
CE246:DBMS 20DCE007

(5) Transfer 10 Rs from account of anil to sunil if both are having same
branch.
update deposit set amount=amount-10 where cname = 'anil' and bname in(select
bname from deposit where cname = 'sunil') update deposit1 set
amount=amount-10 where cname = 'sunil' and bname in(select bname from
deposit1 where cname = 'anil');

(6) Give 100 Rs more to all depositors if they are maximum depositors in
their respective branch.

55 | D E P S T A R - C E
CE246:DBMS 20DCE007

(7) Delete depositors of branches having number of customers between 1 to


3.

(8) Delete deposit of vijay.

56 | D E P S T A R - C E
CE246:DBMS 20DCE007

(9) Delete borrower of branches having average loan less than 1000.

Practical-11
Aim: Add and Remove constraint
57 | D E P S T A R - C E
CE246:DBMS 20DCE007

Queries:
(1) Add primary key constraint on job_id in job table.

(2)Add foreign key constraint on employee table referencing job table.

PRACTICAL-12
AIM:

58 | D E P S T A R - C E
CE246:DBMS 20DCE007

Suppose that as the database administrator (DBA) in a hotel, you have to set up a database
to capture all the following information that the hotel needs to maintain.

 The hotel offers three types of ROOMS, including single room, double room, and triple
room. Every room is Identified by its unique number.

 Every employee at the hotel is either a receptionist, a cleaning staff, or a kitchen staff.
Each RECEP-TIONIST is identified with her/his name, employee number and years of
experience. Receptionists are responsible for ensuring the room is clean before the room is
assigned to the guest. Thus, they assign a single CLEANING STAFF to clean each room every
morning and/or whenever it is required. Note that the same room may need to be cleaned
several times on the same day, before it gets reassigned. For each cleaning assignment, the
date and the status need to be provided. The KITCHEN STAFF is characterized by their
specific responsibilities, e.g. being a cook or a waiter. The cleaning staff and the kitchen staff
are also uniquely identified by their employee number. 2

 Receptionists welcome GUESTS and upon presentation of their valid traveling documents,
they allocate a unique room to each guest and specify one group of facilities which is
accessible to the guest during his stay. Guests are uniquely identified with their passport
number but other necessary information are also recorded about the guests, including:
name, phone numbers, arrival date, departure date, and credit card number. Each FACILITY
GROUP contains specific set of facilities, e.g. the bar or gym, in order to be used by the
guests. The arrival and departure dates of a guest will in turn determine the occupation of a
specific room.

 A guest can be accompanied with one person to have a double room or at most two
people for a triple room. Each ACCOMPANYING person is identified by his/her name. (12.1)
Design Data Dictionary for above problem. (12.2) Considering the descriptions given above,
draw an ER diagram for the database, representing entities, attributes, and relationships.
Hint: Pay attention to clear identification of different kinds of attributes (e.g. multi-valued,
derived, and Primary key), the total participation for the relationship sets and generalization
(or specialization) of entities.

ENTITY ATTRIBUTE DATATYPE LENGTH CONSTAIN


ROOM Roo NUMBER -
Room_NO NUMBER - PRIMARY

59 | D E P S T A R - C E
CE246:DBMS 20DCE007

KEY
CLEANING_STATUS VARCHAR2 20 NOT NULL
CLEAN_DATE DATE 6 NOT NULL

EMPLOYEE EMP_NO NUMBER - PRIMARY


KEY

RECEPTIONIST YEAR OF EXP. NUMBER -


EMP_NO VARCHAR2 32 NOT NULL

CLEANING EMP_NO NUMBER 7 NOT NULL


STAFF DATE
STATUS

KITCHEN EMP_NO NUMBER 7 NOT NULL


STAFF RESPO.

FACILITY GYM VARCHAR2 24 NOT NULL


BAR VARCHAR2 24 NOT NULL

GUEST G_ARRDATE DATE 6 NOT NULL


G_DEPTDATE DATE 6 NOT NULL
G_TRAVELDOCS NUMBER 25 NOT NULL
G_NAME VARCHAR2 32 NOT NULL
G_PHONENUMBER NUMBER 12 NOT NULL
G_CREDITNUMBER NUMBER 12 NOT NULL
G_PASSPORTNUMBER NUMBER 12 PRIMARY
KEY

SINGLE ROOM S_EQUIPMENTS VARCHAR2 -

DOUBLE D_EQUIPMENTS VARCHAR2 -


ROOM

TRIPLE ROOM T_EQUIPMENTS VARCHAR2 -

(3)Add composite primary key on lock table (lock table does not exist,
while creating table add composite key)
create table lock_t(
prod_id int not null,
name varchar(45 ) ,

60 | D E P S T A R - C E
CE246:DBMS 20DCE007

manufacture varchar(45),
primary key(name. manufacture)
)
describe lock_t

(4)Remove primary key constraint on job_id

(5)Remove foreign key constraint on employee table

PRACTICAL-15
Aim:To perform the concept of cursor

61 | D E P S T A R - C E
CE246:DBMS 20DCE007

Queries:
(a) Display all the information of EMP table using %ROWTYPE.

62 | D E P S T A R - C E
CE246:DBMS 20DCE007

63 | D E P S T A R - C E

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy