0% found this document useful (0 votes)
10 views26 pages

Final Lab Manual - BDMS-2024-25

The document is a lab manual for a Database Management System (DBMS) course at Manoharbhai Patel Institute of Engineering and Technology, detailing program-specific outcomes and course outcomes. It covers the introduction to DBMS, its characteristics, advantages, disadvantages, and the implementation of Data Definition Language (DDL) and Data Manipulation Language (DML) commands. The manual also includes various SQL queries and viva voce questions related to the experiments conducted in the lab.

Uploaded by

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

Final Lab Manual - BDMS-2024-25

The document is a lab manual for a Database Management System (DBMS) course at Manoharbhai Patel Institute of Engineering and Technology, detailing program-specific outcomes and course outcomes. It covers the introduction to DBMS, its characteristics, advantages, disadvantages, and the implementation of Data Definition Language (DDL) and Data Manipulation Language (DML) commands. The manual also includes various SQL queries and viva voce questions related to the experiments conducted in the lab.

Uploaded by

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

MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND

TECHNOLOGY SHAHAPUR, BHANDARA


DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual
Program Specific Outcome (PSO)
PSO1.
An ability to apply mathematical foundations, algorithmic principles and computer
science theory in the modeling and design, computer based system in a way that
demonstrates comprehension of the trade offs involve in design choices.
PSO2. An ability to apply design and development principles in the construction of software
systems of varying complexity.
PSO3. An ability to use techniques, skills and modern engineering tools necessary for
engineering practice, and an ability to communicate effectively.

Course Outcome (CO)


After completion of this subject the student will learn
1. Acquire knowledge of handling large volume of data.
2. Acquire skills to deal with Real life database implementation.
3. Response off faster queries and serve as many users as possible concurrently.
4. Fit with any Database project in industry after completion of degree.

EXPERIMENT NO – 1
Aim:- Introduction to DBMS

Theory:
DBMS (Database Management System)
A DBMS is software that allows creation, definition and manipulation of database,
allowing users to store, process and analyze data easily. DBMS provides us with an interface
or a tool, to perform various operations like creating database, storing data in it, updating
data, creating tables in the database and a lot more.
DBMS also provides protection and security to the databases. It also maintains data
consistency in case of multiple users.
Here are some examples of popular DBMS used these days:
 MySql
 Oracle
 SQL Server
 IBM DB2
 PostgreSQL
 Amazon SimpleDB (cloud based) etc.
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Characteristics of Database Management System


A database management system has following characteristics:
1. Data stored into Tables: Data is never directly stored into the database. Data is
stored into tables, created inside the database. DBMS also allows having relationships
between tables which makes the data more meaningful and connected. You can easily
understand what type of data is stored where by looking at all the tables created in a
database.
2. Reduced Redundancy: In the modern world hard drives are very cheap, but earlier
when hard drives were too expensive, unnecessary repetition of data in database was a
big problem. But DBMS follows Normalization which divides the data in such a way
that repetition is minimal.
3. Data Consistency: On Live data, i.e. data that is being continuously updated and
added, maintaining the consistency of data can become a challenge. But DBMS
handles it all by itself.
4. Support Multiple user and Concurrent Access: DBMS allows multiple users to
work on it (update, insert, and delete data) at the same time and still manages to
maintain the data consistency.
5. Query Language: DBMS provides users with a simple Query language, using which
data can be easily fetched, inserted, deleted and updated in a database.
6. Security: The DBMS also takes care of the security of data, protecting the data from
un-authorized access. In a typical DBMS, we can create user accounts with different
access permissions, using which we can easily secure our data by restricting user
access.
7. DBMS supports transactions, which allows us to better handle and manage data
integrity in real world applications where multi-threading is extensively used.

Advantages of DBMS
 Segregation of application program.
 Minimal data duplicity or data redundancy.
 Easy retrieval of data using the Query Language.
 Reduced development time and maintenance need.
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual
 With Cloud Datacenters, we now have Database Management Systems capable of
storing almost infinite data.
 Seamless integration into the application programming languages which makes it very
easier to add a database to almost any application or website.
Disadvantages of DBMS
 It's Complexity
 Except MySQL, which is open source, licensed DBMSs are generally costly.
 They are large in size.
RDBMS (Relational Database management System)
A Relational Database management System (RDBMS) is a database management
system based on the relational model introduced by E.F Codd. In relational model, data is
stored in relations (tables) and is represented in form of tuples (rows).
RDBMS is used to manage Relational database. Relational database is a collection of
organized set of tables related to each other, and from which data can be accessed easily.
Relational Database is the most commonly used database these days.
In relational model in which data is stored in multiple tables where tables are related to each
other using primary keys and foreign keys and indexes. RDBMS uses database normalization
techniques to avoid redundancy in tables. It helps to fetch data faster using SQL query. It is
widely used by enterprises and software developers to store large amount of complex data
Examples:
 SQL server,
 Oracle
 MySQL
 MariaDB
 SQLite

Important Concept Related to RDBMS:

Table
In Relational database model, a table is a collection of data elements organized in terms of
rows and columns. A table is also considered as a convenient representation of relations. But
a table can have duplicate row of data while a true relation cannot have duplicate data. Table
is the simplest form of data storage. Below is an example of an Employee table.
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

ID Name Age Salary

1 Adam 34 13000

2 Alex 28 15000

3 Stuart 20 18000

4 Ross 42 19020

Tuple
A single entry in a table is called a Tuple or Record or Row. A tuple in a table represents a
set of related data. For example, the above Employee table has 4 tuples/records/rows.
Following is an example of single record or tuple.

1 Adam 34 13000

Attribute
A table consists of several records (row), each record can be broken down into several
smaller parts of data known as Attributes. The above Employee table consists of four
attributes, ID, Name, Age and Salary.

Attribute Domain
When an attribute is defined in a relation (table), it is defined to hold only a certain type of
values, which is known as Attribute Domain. Hence, the attribute Name will hold the name
of employee for every tuple. If we save employee's address there, it will be violation of the
Relational database model.

Name

Adam

Alex

Stuart - 9/401, OC Street, Amsterdam


MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual
Advantages of RDBMS
 It is easy to use.
 It is secured in nature.
 The data manipulation can be done.
 It limits redundancy and replication of the data.
 It offers better data integrity.
 It provides better physical data independence.
 It offers logical database independence i.e. data can be viewed in different ways by
the different users.
 It provides better backup and recovery procedures.
 It provides multiple interfaces.
 Multiple users can access the database which is not possible in DBMS.
Disadvantages of RDBMS
 Software is expensive.
 Complex software refers to expensive hardware and hence increases overall cost to
avail the RDBMS service.
 It requires skilled human resources to implement.
 Certain applications are slow in processing.
 It is difficult to recover the lost data.

Conclusion: Thus we, have studied DBMS, RDBMS with its advantages and disadvantages
successfully.

Viva Voce Questions (Experiment-1)


1. Define Database? What are DBMS and RDBMS?
2. What do you understand by Data Redundancy?
3. Enlist Database System applications.
4. What is mean by data abstraction? Enlist different levels of data abstraction.
5. Give the definition of instance and schema.
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual
Experiment No.2

Aim:- Implement Data Definition Language (Create, Alter, Drop, Truncate


and Rename)
Theory:

DDL: A data definition language or data description language (DDL) is syntax similar to a
computer programming language for defining data structures, especially database schemas.-
Commands in DDL are:

a. CREATE
b. DROP
c. TRUNCATE
d. RENAME
e. ALTER.

DDL COMMANDS SYNTAX:

a) CREATE Statement:
Create table <tablename> (<column_name1 > <data_ type_1>, <column_name2> <data_
type _2>,……,<column_nameN > <data_ type_N>, ……<.constraint1>, <constraint2>,
…….);

b) DROP:
DROP TABLE < table_name>;

c) TRUNCATE: The SQL TRUNCATE TABLE command is used to delete complete data
from an existing table.
TRUNCATE TABLE <table_name>;

d) RENAME: It is used to change the name of a table.

RENAME TABLE <old_table_name> TO <new_tbl_name>;

e) ALTER:

For adding column to Table:

ALTER TABLE <table_name> ADD <column_name> <Domain>;

For modifying column to Table:

ALTER TABLE <table_name> MODIFY COLUMN <column_name> <data_type>;


MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual
For removing column from Table:

ALTER TABLE <table_name > DROP <column_name>;

Note: Solve the following queries and show respective results on blank side of record
book.

DDL QUERIES:

Q1. Write a query to create a table employee with empno, ename, designation, and salary.

SQL>CREATE TABLE EMP (EMPNO NUMBER (4), ENAME VARCHAR(10),


DESIGNATIN VARCHAR (10), SALARY NUMBER (8,2));

Q2. Write a query for create a from an existing table with all the fields.

SQL> CREATE TABLE EMP1 AS SELECT * FROM EMP;

Q3. Write a Query to Alter the column EMPNO NUMBER(4) TO EMPNO NUMBER(6).

SQL>ALTER TABLE EMP MODIFY EMPNO NUMBER (6);

Q4. Write a query to add a new column in to employee.

SQL> ALTER TABLE EMP ADD QUALIFICATION VARCHAR (6);

Q5. Write a query to drop a column from an existing table employee.

SQL> ALTER TABLE EMP DROP COLUMN DOJ;

Q6. Write a query to drop an existing table employee.

SQL> DROP table employee;

Conclusion: Thus we, have implemented Data Definition Language commands (Create,
Alter, Drop, Truncate, and Rename) successfully.

Viva Voce Questions (Experiment-2)

1. What is SQL?
2. What is difference between Truncate and Drop Command?
3. What is difference between Truncate and Delete Command?
4. What is mean by integrity constraints?
5. What are different integrity constraints?
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual
Experiment No.3

Aim:- Implement Data Manipulation Language (Insert, Update, and


Delete)
Theory:-

DML: A data manipulation language (DML) is a family of syntax elements similar to a


computer programming language used for selecting, inserting, deleting and updating data in a
database. Performing read-only queries of data is sometimes also considered a component of
DML.

Commands in DML are:

a.INSERT
b.UPDATE
c.DELETE
d.SELECT

DML COMMANDS:

SYNTAX:

a) INSERT Statement: The INSERT statement is a SQL query. It is used to insert data into
the row of a table.

INSERT INTO <table_name> VALUES (value1, value2, value3, .... valueN);

Or
INSERT INTO <TABLE_NAME> (col1, col2, col3,.... col N) VALUES (value1, value2, val
ue3, .... valueN);

b) UPDATE Statement: This command is used to update or modify the value of a column in
the table.

UPDATE <table_name> SET [column_name1= value1,……...column_nameN = valueN] [W


HERE CONDITION];

c) DELETE Statement: It is used to remove one or more row from a table.

DELETE FROM <table-name >[WHERE search- condition];


MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

d.SELECT statement : SELECT statement is used to query or retrieve data from a table in
the database. The returns data is stored in a table, and the result table is known as result-set.

SELECT <column1, column2, ...> FROM <table_name> [ WHERE condition];


OR

SELECT * FROM <table_name> [ WHERE condition];

Note: Solve the following queries and show respective results on blank side of record
book.

DML QUERIES:

Q1. Write a query to insert the records in to employee.

SQL>INSERT INTO EMPLOYEE VALUES (103,'Saurabh','ASST_PROF',25000);

SQL>INSERT INTO EMPLOYEE VALUES (105,'Ashish','ASST_PROF',27000);

Q2. Write a query to display the records from employee.

SQL> SELECT * FROM EMPLOYEE;

Q3. Write a query to update the records from employee.

SQL> UPDATE EMPLOYEE SET SALARY=45000 WHERE EMPNO=101;

SQL> SELECT * FROM EMPLOYEE;

Q4. Write a query to delete the records from employee.

SQL> DELETE FROM EMPLOYEE WHERE EMPNO=101;

Conclusion: Thus we, have implemented Data Manipulation Language (Select,Insert,


Update, and Delete) successfully.

Viva Voce Questions (Experiment-3)

1. What is DML?
2. What is mean by extension?
3. What is difference between DROP and DELETE Command?
4. What is indexing?
5. What are basic data types in SQL?
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Experiment No.4

Aim: - Implement SQL queries using different types of operators.


Theory:-

An operator is a reserved word or a character used primarily in an SQL statement's WHERE


clause to perform operation(s), such as comparisons and arithmetic operations. These
Operators are used to specify conditions in an SQL statement and to serve as conjunctions for
multiple conditions in a statement.

 Arithmetic operators

 Comparison operators

 Logical operators

Note: Solve the following queries and show respective results on blank side of record
book
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Conclusion: Thus we have implemented SQL queries using different types of operators
successfully.

Viva Voce Questions (Experiment-4)

1. What is use of BETWEEN operator?


2. What is mean by null value?
3. What is use of LIKE operator?
4. What is use of EXISTS operator?
5. What is use of UNIQUE and IN operator?
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Experiment No.5

Aim: - Implement SQL queries for Aggregate functions.


Theory:

Aggregate functions are functions that take a collection (a set or multiset) of values as input
and return a single value. SQL offers five built-in aggregate functions. It is also used to
summarize the data. This type of scenario is where you would use a group functions.

The following table is summary of five built-in aggregate functions.

To use a group function in a SQL query, list the function name followed by numeric
column name within parentheses. AVG averages the column, COUNT counts the number of
items, MAX returns maximum number of the column, and MIN returns minimum number of
the column .The following is query to retrieve total price, average price, maximum price, and
minimum price from the table “product” assuming the product table has the following values.
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Note: Solve the following queries and show respective results on blank side of record
book

Q1. Write a query find the total price of the product.

SQL>SELECT sum(price) FROM product;

SUM(PRICE) 870 This statement will returns the total amount for the column price which is
870.

Q2. Write a query find the average price of the product.

SQL>SELECT avg(price) FROM product;

Avg(price) 217.50 This statement will returns the average amount for the column price which
is 870/4 or 217.50.

Q3. Write a query find the max price of the product.

SELECT max(price) FROM product;

Max(price) 300 This statement will returns the maximum amount for the column price which
is 300

Q4. Write a query find the minimum price of the product.


MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual
SELECT min(price) FROM product;

Min(price) 120 This statement will returns the maximum amount for the column price which
is 120

Q5. Write a query to count number of product.

SELECT count (*) FROM product;

Conclusion: Thus we have implemented SQL queries for Aggregate functions successfully.

Viva Voce Questions (Experiment-5)

1. What is use of ALL keyword?


2. What is use of DISTINCT keyword?
3. What is GROUP BY clause?
4. What is HAVING clause?
5. Can we use two aggregate functions in SQL?
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Experiment No.6

Aim: - Implement SQL queries for set operations.


Theory:

DBMS supports relational set operators. Set operations correspond to the mathematical set-
theory operations ∪, ∩, and −.The major relational set operators are union, intersection and
set difference. All of these can be implemented in DBMS using different queries.

Create following tables:

Table 1: Art_Students

Table 2: Dance_Students

1. Union

Union combines two different results obtained by a query into a single result in the
form of a table. However, the results should be similar if union is to be applied on them.
Union removes all duplicates, if any from the data and only displays distinct values. If
duplicate values are required in the resultant data, then UNION ALL is used.

An example of union is:

Select Student_Name from Art_Students

UNION

Select Student_Name from Dance_Students;


MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

This will display the names of all the students in the table Art_Students and Dance_Students
i.e John, Mary, Damon and Matt.

2. Intersection
The intersection operator gives the common data values between the two data sets that
are intersected. The two data sets that are intersected should be similar for the intersection
operator to work. Intersection also removes all duplicates before displaying the result.
An example of intersection is:

Select Student_Name from Art_Students

INTERSECT

Select Student_Name from Dance_Students;

This will display the names of the students in the table Art_Students and in the table
Dance_Students i.e all the students that have taken both art and dance classes .Those are
Mary and Damon in this example.

3. Set difference (except)


The set difference operator takes the two sets and returns the values that are in the first set but
not the second set.
An example of set difference is

Select Student_Name from Art_Students

MINUS/EXCEPT

Select Student_Name from Dance_Students

This will display the names of all the students in table Art_Students but not in table
Dance_Students i.e the students who are taking art classes but not dance classes.
That is John in this example.
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Conclusion: Thus we have implemented SQL queries for set operations successfully

Viva Voce Questions (Experiment-6)

1. What are the different set operations in DBMS?


2. What is use of UNION ALL?
3. What is use of INTERSECT ALL?
4. What is use of EXCEPT ALL?
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Experiment No.7

Aim: - Implement SQL queries for sub queries, nested queries and to
create views.
Theory:

Nested Queries: Nesting of queries one within another is known as a nested queries. Sub
queries. The query within another is known as a sub query. A statement containing sub query
is called parent statement. The rows returned by sub query are used by the parent statement.

Types

1. Sub queries that return several values Sub queries can also return more than one value.
Such results should be made use along with the operators in and any.

2. Multiple queries here more than one sub query is used. These multiple sub queries are
combined by means of “and” & “or‟ keywords.

3. Correlated sub query: A sub query is evaluated once for the entire parent statement
whereas a correlated Sub query is evaluated once per row processed by the parent statement.

Relating Data through Join Concept

The purpose of a join concept is to combine data spread across tables. A join is actually
performed by the “where‟ clause which combines specified rows of tables.Syntax; select
columns from table1, table2 where logical expression.

Types of Joins

1. Simple Join 2.Self Join 3. Outer Join 4. Inner Join

1. Simple Join

a) Equi-join: A join, which is based on equalities, is called equi-join.

b) Non Equi-join: It specifies the relationship between Table Aliases [Table aliases are used
to make multiple table queries shorted and more readable. We give an alias name to the table
in the “from‟ clause and use it instead of the name throughout the query].
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual
Self join: Joining of a table to itself is known as self-join. It joins one row in a table to
another. It can compare each row of the table to itself and also with other rows of the same
table.

Outer Join: It extends the result of a simple join. An outer join returns all the rows returned
by simple join as well as those rows from one table that do not match any row from the table.
The symbol (+) represents outer joins.

Inner join: Inner join returns the matching rows from the tables that are being joined.

Q1. Display all employee names and salary whose salary is greater than minimum salary of
the company and job title starts with “A‟.

SQL>select ename,sal from emp where sal>(select min(sal) from emp where job like 'A%');

Output:

View:

A view is nothing more than a SQL statement that is stored in the database with an
associated name. A view is actually a composition of a table in the form of a predefined SQL
query.

A view can contain all rows of a table or select rows from a table. A view can be created
from one or many tables which depends on the written SQL query to create a view. Views,
which are a type of virtual tables allow users to do the following −

 Structure data in a way that users or classes of users find natural or intuitive.

 Restrict access to the data in such a way that a user can see and (sometimes) modify
exactly what they need and no more.
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual
 Summarize data from various tables which can be used to generate reports.

Syntax: CREATE VIEW <view_name > AS SELECT column1,column2,.... FROM


table_name WHERE condition;

Queries:

Q1. Write a SQL query to create a view of customer table created in PRACTICAL no 1.

SQL>CREATE VIEW CUST as Select ID, Name, Address From Customer;

Output:

Conclusion: Thus we have implemented SQL queries for sub queries, nested queries and to
create views successfully.

Viva Voce Questions (Experiment-7)

1. What is use of Set Membership?


2. What is use of Set Comparison?
3. What is mean by materialized view?
4. What is mean by materialized view maintenance?
5. Which operators are used to test for Empty Relations and test for the Absence of
Duplicate Tuples respectively?
6. What is use of with Clause?
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Experiment No.8

Aim: - Implement queries to understand the concepts for ROLL BACK,


COMMIT & CHECK POINTS.
Theory:

Transaction Control Language (TCL) commands are used to manage transactions in database.
These are used to manage the changes made by DML statements. It also allows statements to
be grouped together into logical transactions. Commit command Commit command is used to
permanently save any transaction into database.

Following is Commit command's syntax,

COMMIT;

Rollback command

This command restores the database to last commited state. It is also use with savepoint
command to jump to a savepoint in a transaction.

Following is Rollback command's syntax,

rollback to savepoint-name;

Savepoint command

Savepoint command is used to temporarily save a transaction so that you can rollback to that
point whenever necessary.

Following is savepoint command's syntax,

Savepoint <savepoint-name>;

QUERY:

Q1. Write a query to implement the save point.


MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

SQL> select employee.empno, employee.ename, employee.salary, department.dname,


department.location From department, employee Where department.deptno =
employee.empno;

SQL> SAVEPOINT S1;

Q2. Write a query to implement the Rollback.

SQL>ROLL BACK S1;

Conclusion: Thus we have implemented SQL queries to understand the concepts for ROLL
BACK, COMMIT & CHECK POINTS successfully.

Viva Voce Questions (Experiment-8)

1. What is mean by Transaction?


2. What are the ACID properties in DBMS?
3. What is role of recovery manager?
4. What is role of concurrency control manager?
5. What are the different states of transaction?
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Experiment No.9

Aim: - Implement SQL queries for different JOINS.


Theory:

A SQL join clause combines columns from one or more tables in a relational
database. It creates a set that can be saved as a table or used as it is. A JOIN is a means for
combining columns from one (self-table) or more tables by using values common to each.
ANSI-standard SQL specifies five types of JOIN: INNER, LEFT OUTER, RIGHT OUTER,
FULL OUTER and CROSS. As a special case, a table (base table, view, or joined table) can
JOIN to itself in a self-join.

A programmer declares a JOIN statement to identify rows for joining. If the evaluated
predicate is true, the combined row is then produced in the expected format, a row set or a
temporary table.

Q1. Display the employee details, departments that the departments are same in both the emp
and dept.

SQL>select * from emp,dept where emp.deptno=dept.deptno;


MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Output:

Conclusion: Thus we have implemented SQL queries for different JOINS successfully.

Viva Voce Questions (Experiment-9)

1. What is the use of joins in SQL?


2. Can we join 3 tables in SQL?
3. What are the different types of join operations?
4. What is inner join and outer join?
5. IS LEFT JOIN same as JOIN?
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual

Experiment No.10

Aim: - Implement program by using PL/SQL.


Theory:

The PL/SQL programming language was developed by Oracle Corporation in the late 1980s
as procedural extension language for SQL and the Oracle relational database. PL/SQL has the
following features −

 PL/SQL is tightly integrated with SQL.

 It offers extensive error checking.

 It offers numerous data types.

 It offers a variety of programming structures.

 It supports structured programming through functions and procedures.

 It supports object-oriented programming.

 It supports the development of web applications and server pages.

Query:

DECLARE
a number (2) := 21;
b number (2) := 10;
BEGIN
IF (a = b) then
dbms_output.put_line('Line 1 - a is equal to b');
ELSE
dbms_output.put_line('Line 1 - a is not equal to b');
END IF;
IF (a < b) then
dbms_output.put_line('Line 2 - a is less than b');
MANOHARBHAI PATEL INSTITUTE OF ENGINEERING AND
TECHNOLOGY SHAHAPUR, BHANDARA
DEPARTMENT OF COMPUTER ENGINEERING
Semester : FIFTH Subject Code: BTCME501P DBMS Lab Manual
ELSE
dbms_output.put_line('Line 2 - a is not less than b');
END IF;
IF ( a> b ) THEN
dbms_output.put_line('Line 3 - a is greater than b');

ELSE

dbms_output.put_line('Line 3 - a is not greater than b');

END IF;

END;

Output:
Line 1 - a is not equal to b
Line 2 - a is not less than b
Line 3 - a is greater than b

Conclusion: Thus we have implemented program by using of PL/SQL.

Viva Voce Questions (Experiment-10)

1. What is PL SQL and what is it used for?


2. What is difference between SQL and Plsql?
3. What is PL SQL engine?
4. Which software is used for PL SQL programming?
5. Where is PL SQL used?

*******************************************

You might also like