0% found this document useful (0 votes)
4 views

Dbms Lab Manual

The document is a laboratory manual for the Database Management course at SAL Institute of Diploma Studies, detailing various experiments and objectives related to database concepts and SQL commands. It covers topics such as current database trends, ER diagrams, SQL operations, data constraints, and user management in databases. Each experiment includes objectives, theory, and exercises to enhance students' understanding of database management systems.

Uploaded by

shubhamvj41
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Dbms Lab Manual

The document is a laboratory manual for the Database Management course at SAL Institute of Diploma Studies, detailing various experiments and objectives related to database concepts and SQL commands. It covers topics such as current database trends, ER diagrams, SQL operations, data constraints, and user management in databases. Each experiment includes objectives, theory, and exercises to enhance students' understanding of database management systems.

Uploaded by

shubhamvj41
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

SAL Institute of Diploma Studies, AHMEDABAD

Department of Information Technology


Database Management (4331603)

Laboratory Manual
Semester: III

Year: 2024-2025

PREPARED BY:

DEVANS THAKAR
AMI PATEL
INDEX
Page No.
Sr.No. Experiment CO Date Marks Signature
From To
1. Prepare a report on current database
a
trends, architecture and tools.
2. Draw ER-Diagram for Banking b
Management System and convert it &
relational schema c
3. Design the given schemas using SQL
Command -”Create”. Decide the appropriate
data type for each column. Insert data in
d
tables using SQL Command”Insert”.
Retrieve data from tables in Practical 2
using Data SQL command- “Select”
4.
Write SQL queries to use Update, alter,
d
rename, delete, truncate and distinct.
5. Write SQL queries to use various date
functions, numeric functions, character d
functions, conversion functions
6. Write SQL queries to use various group
function and operators, set operators and
d
join operations using tables created in
Practical 1.
7.
Apply the concept of integrity/data
d
constraints while creating/altering a table:
8. Write SQL queries for CREATE
USER,GRANT, REVOKE AND DROP
USER command. Prepare a report on d
&
transaction management concepts for
f
concurrent access of database by multiple
users.
9. Write a program in PL/SQL to show the
user of Cursor, user of Stored Procedures d
and Function.
10. Write a program in PL/SQL to show the d
user of Database Triggers and &
Normalization of database e

Page no____________
Experiment No: 1 Date: / /

TITLE: To study about Current database trends, architecture and tools.

OBJECTIVES:

After completing this experiment students will be able to…


● Fundamentals of Database and DBMS
● Get to know architecture of DBMS
● Knowledge of various database tools

THEORY:

What is Database?
A database consists of an organized collection of interrelated data. There are many databases
available like MySQL, Sybase, Oracle, MongoDB, Informix, PostgreSQL, SQL Server, etc.

Modern databases are managed by the database management system (DBMS).

EXERCISES:
1. Explain current trends, architecture and tools in database .

Problem Analysis Understanding Timely Mock Total


& Solution Level Completion (2) (10)
(3) (3) (2)

Signature : __________________________

Date : __________________________

Page no____________
Experiment No: 2 Date: / /

TITLE: Draw ER-Diagram for Banking Management System and convert it relational
schema

OBJECTIVES:

After completing this experiment students will be able to…


● Draw ER model for any system
● Interpret ER diagram to understand relationships among attributes

THEORY:
The Entity Relational Model is a model for identifying entities to be represented in the database
and representation of how those entities are related. The ER data model specifies enterprise
schema that represents the overall logical structure of a database graphically.

The Entity Relationship Diagram explains the relationship among the entities present in the
database. ER models are used to model real-world objects like a person, a car, or a company and
the relation between these real-world objects. In short, the ER Diagram is the structural format of
the database.

EXERCISES:
1. Draw ER-Diagram for Banking Management System and convert it into relational
schema.

Problem Analysis Understanding Timely Mock Total


& Solution Level Completion (2) (10)
(3) (3) (2)

Signature : __________________________

Date : __________________________

Page no____________
Experiment No: 3 Date: / /

TITLE: Design the given schemas using SQL Command -”Create”. Decide the appropriate
data type for each column. Insert data in above tables using SQL Command”Insert”. Retrieve
data from tables in Practical 2 using Data SQL command- “Select”

After completing this experiment students will be able to…


● Create table and describe the table
● Perform morphological operations on the image
● Develop a program for different image segmentation techniques
● View inserted data in the table

THEORY:
CREATE TABLE Command :
● The CREATE TABLE command defined each column of the table uniquely.
● Each column has a minimum of three attributes: name, datatype, size.

Syntax
CREATE TABLE <TableName> (<ColumnName1> <DataType>(<size>), <ColumnName2>
<DataType>(<size>));

DESCRIBE Statement:

DESCRIBE is used to describe something. Since in a database, we have tables, that’s why do we
use DESCRIBE or DESC(both are the same) commands to describe the structure of a table.

Inserting Data Into Tables


Load the values passed into the column specified.

Syntax
INSERT INTO <tablename> (<columnname1> <columnname2>)VALUES (<expression1>
, < expression2>);

Viewing data in the table


● Once data has been inserted into a table. Next operation would be to view data into the table.
● For that SELECT SQL verb is used. To retrieve data from the table.

Retrieve all rows and all columns


● SELECT <ColumnName 1> To <ColumnName N> FROM TableName;

Selected all rows and columns


● SELECT <ColumnName 1>, <ColumnName 2> FROM <TableName>;

Page no____________
Selected rows and all columns
● SELECT * FROM <TableName> WHERE <Condition>;

Selected rows and selected columns


● SELECT <ColumnName 1>,<ColumnName 2> FROM <TableName> WHERE
<Condition>;

EXERCISES:
1. Create a table ACCOUNT with column account number, name, city, balance, loan taken.
2. Create a LOAN table with column loan number, account number, loan amount, interest
rate, loan date, and remaining loan.
3. Create table INSTALLMENT with column loan number, installment number, installment
date and amount.
4. Create table TRANSACTION with column account number, transaction date, amount,
type of transaction, mode of payment.
5. Show the structure of above tables using “Describe” command.
6. Insert data into these tables using SQL Command ”Insert”.
7. Display all rows and all columns of table Transaction.
8. Display all rows and selected columns of table Installment.
9. Display selected rows and selected columns of table Account.
10. Display selected rows and all columns of table loan.
11. Display the branch wise balance from account table.
12. Display list of those branches that have balance greater than 1 Lakh rupees.
13. Display the list of customers in descending order of their name from account table.
14. Display the list of customers in descending order of their name from account table.

Problem Analysis Understanding Timely Mock Total


& Solution Level Completion (2) (10)
(3) (3) (2)

Signature : __________________________

Date : __________________________

Page no____________
Experiment No: 4 Date: / /

TITLE: Write SQL queries to use Update, alter, rename, delete, truncate and distinct.

OBJECTIVES:

After completing this experiment students will be able to…


● Perform update, alter, rename, delete, truncate and distinct operations on table

THEORY:
The UPDATE statement in SQL is used to update the data of an existing table in the database.
We can update single columns as well as multiple columns using the UPDATE statement as per
our requirement.

Update the content of table.

⮚ Update <TableName> set <ColumnName1> = <Expression1>,<ColumnName2> =


<Expression 2>;

Delete record on condition.

⮚ DELETE FROM <tablename> where <columnname> = <expression>

Adding new columns

⮚ ALTER TABLE <TableName>

(<NewColumnName> <DataType>(<size>), <NewColumnName> <DataType>(<size>)...);

Dropping a column from a table

⮚ ALTER TABLE <TableName> DROP COLUMN <ColumnName>

Modifying Existing Columns

⮚ ALTER TABLE <tablename>

MODIFY(<ColumnName> <NewDataType>(<NewSize>));
Rename the table

⮚ RENAME <TableName> To <NewTableName>

TRUNCATE

TRUNCATE statement is a Data Definition Language (DDL) operation that is used to mark the
extent of a table for deallocation (empty for reuse). The result of this operation quickly removes
Page no____________
all data from a table.

Syntax

TRUNCATE TABLE <TableName>;

EXERCISES:
1. Change the name ‘pateljigar’ to ‘patelhiren’.
2. Change the name and city where account number is A005. (new name = ‘kotharinehal’
and new city = ‘patan’).
3. Add the new column (address varchar2 (20)) into table ACCOUNT.
4. Rename the table ACCOUNT to ACCOUNT_MASTER.
5. Delete the records whose account no is A004.
6. Display unique records of column city from account_master.

Problem Analysis Understanding Timely Mock Total


& Solution Level Completion (2) (10)
(3) (3) (2)

Signature : __________________________

Date : __________________________

Page no____________
Experiment No: 5 Date: / /

TITLE: Write SQL queries to use various date functions, numeric functions, character
functions, conversion functions.

OBJECTIVES:

After completing this experiment students will be able to…


● Learn various date and time functions
● Learn various numeric functions and their applications
● Learn various character functions

THEORY:
For storing a date or a date and time value in a database,MySQL offers the following data types:

EXERCISES:
1. Write SQL Queries to demonstrate date functions.
2. Write SQL Queries to demonstrate Numeric functions.
3. Write SQL Queries to demonstrate Character functions.
4. Write SQL Queries to demonstrate Conversion functions.

Problem Analysis Understanding Timely Mock Total


& Solution Level Completion (2) (10)
(3) (3) (2)

Signature : __________________________

Date : __________________________
Page no____________
Experiment No: 6 Date: / /

TITLE: Write SQL queries to use various group function and operators, set operators and
join operations using tables created in Practical 1.

OBJECTIVES:

After completing this experiment students will be able to…


● Apply grouping function and operators
● Perform motion estimation
● Develop a program in python for various motion estimation techniques

THEORY:-

GROUPING DATA FROM TABLES IN SQL GROUP BY Clauses


The GROUP BY clause is another section of the select statement. The optional clauses tells
Oracles to groups rows based on distinct values that for specified columns. The GROUP BY
clause create a data set containing several sets of records grouped together based on a condition.
HAVING Clause
The HAVING clause can be used in conjunction with the GROUP BY clause.HAVING imposes
a condition on the GROUP BY clause,which further the groups created by GROUP BY
clause.Each column specification specified in the HAVING clause must occur within a statistical
function or must occur in the list of columns named in the GROUP BY clause.
EXERCISES:
1. Demonstrate Group Functions in SQL.
2. Demonstrate SET Operators in SQL.

Problem Analysis Understanding Timely Mock Total


& Solution Level Completion (2) (10)
(3) (3) (2)

Signature : __________________________

Date : __________________________

Page no____________
Experiment No: 7 Date: / /

TITLE: Apply the concept of integrity/data constraints while creating/altering a table:

OBJECTIVES:

After completing this experiment students will be able to…


● Perform motion estimation
● Develop a program in python for various motion estimation techniques

THEORY:

Data constraints: Besides the cell name, cell length and cell data type there are other parameters
i.e. other data constrains that can be passed to the DBA at check creationtime. The constraints
can either be placed at column level or at the table level.
Column Level Constraints: If the constraints are defined along with the column
definition, it is called a column level constraint.
Table Level Constraints: If the data constraint attached to a specify cell in a table reference the
contents of another cell in the table then the user will have to use table level constraints.
Null Value Concepts:- while creating tables if a row locks a data value for particular column
that value is said to be null . Column of any data types may contain null values unless the column
was defined as not null when the table was created.
Syntax:
Create table tablename (columnname data type (size) not null ……)
Primary Key: primary key is one or more columns is a table used to uniquely identity each row
in the table. Primary key values must not be null and must be unique across the column. A
multicolumn primary key is called composite primary key.
Syntax: primary key as a column constraint
Create table tablename (columnname datatype (size) primary key,….)
Foreign Key Concept : Foreign key represents relationship between tables. A foreign key is
column whose values are derived from the primary key of the same of some other table . the
existence of foreign key implies that the table with foreign key is related to the primary key table
from which the foreign key is derived .A foreign key must have corresponding primary key value
in the primary key table to have meaning.

Page no____________
Syntax : Foreign key as a column constraint.
Create table table name (columnname datatype (size) references another table name);
Syntax : Foreign key as a table constraint:
Create table name (columnname datatype (size)…. primary key (columnname);
foreign key (columnname) references table name);

EXERCISES:
1. Apply the concepts of primary key on the table.
2. Apply the concepts of Foreign ken on the table.

Problem Analysis Understanding Timely Mock Total


& Solution Level Completion (2) (10)
(3) (3) (2)

Signature : __________________________

Date : __________________________

Page no____________
Experiment No: 8 Date: / /

TITLE: Write SQL queries for CREATE USER, GRANT, REVOKE AND DROP USER
command. Transaction management concepts for concurrent access of database by
multiple users.

OBJECTIVES:

After completing this experiment students will be able to…


● To create, delete the user as well as give and revoke the various permission to and from
user
● To create, delete the user as well as give and revoke the various permission to and from
user

THEORY:

CREATE USER Statement

The CREATE USER statement in MySQL allows us to create new MySQL accounts or in other
words, the CREATE USER statement is used to create a database account that allows the user
to log into the MySQL database.
Syntax:
The syntax for the CREATE USER statement in MySQL is:
CREATE USER user_account IDENTIFIED BY password;
Parameters used:
1. user_account: It is the name that the user wants to give to the database account.The
user_account should be in the format ‘username’@’hostname’
2. password:It is the password used to assign to the user_account.The password is specified
in the IDENTIFIED BY clause.

GRANT Statement
The grant statement enables system administrators to assign privileges and roles to
the MySQL user accounts so that they can use the assigned permission on the database whenever
required.
Syntax
The following are the basic syntax of using the GRANT statement:
GRANT privilege_name(s)

Page no____________
ON object
TO user_account_name;

REVOKE Statement
The revoke statement enables system administrators to revoke privileges and roles to the
MySQL user accounts so that they cannot use the assigned permission on the database in the
past.
Syntax
The following are the basic syntax of using the REVOKE statement:
REVOKE privilege_name(s)
ON object
FROM user_account_name;
Drop User
The MySQL Drop User statement allows us to remove one or more user accounts and
their privileges from the database server. If the account does not exist in the database server, it
gives an error.
If you want to use the Drop User statement, it is required to have a global privilege of Create
User statement or the DELETE privilege for the MySQL system schema.
Syntax
The following syntax is used to delete the user accounts from the database server completely.
DROP USER 'account_name';

EXERCISES:
1. Demonstrate Grant and Revoke Commands.

Problem Analysis Understanding Timely Mock Total


& Solution Level Completion (2) (10)
(3) (3) (2)

Signature : __________________________

Date : __________________________

Page no____________
Experiment No: 9 Date: / /

TITLE: Write a program in PL/SQL to show the user of Cursor, Stored Procedures and
Functions.

OBJECTIVES:

After completing this experiment students will be able to…


● learn various cursor operations

THEORY:

Cursors

A cursor is a temporary work area created in the system memory when a SQL statement is
executed. A cursor contains information on a select statement and the rows of data accessed by
it. This temporary work area is used to store the data retrieved from the database, and
manipulate this data. A cursor can hold more than one row, but can process only one row at a
time. The set of rows the cursor holds is called the active set.
EXERCISES:
1. Write a program in PL/SQL to show the user of Cursor.
2. Write a program in PL/SQL to show the user of Stored Procedure.
3. Write a program in PL/SQL to show the user of Stored Function.
Problem Analysis Understanding Timely Mock Total
& Solution Level Completion (2) (10)
(3) (3) (2)

Signature : __________________________

Date : __________________________

Page no____________
Experiment No: 10 Date: / /

TITLE: Write a program in PL/SQL to show the user of Database Triggers. Study about
Normalization of database

OBJECTIVES:

After completing this experiment students will be able to…


● Usage of triggers and its applications

THEORY:

DATABASE TRIGGERS
Database triggers are database objects created via the SQL * Plus tool on the client and stored on the
Server in the Oracle engine's system table. These database objects consist of the following distinct
sections:
● A named database event
● A PLlSQL block that will execute when the event occurs

The occurrence of the database event is strongly bound to table data being changed.

EXERCISES:
1. Write a program in PL/SQL to show the use of Database Triggers.
2. Normalization of database. Consider the following relational schema:
a)Employee(eid, ename, salary, mngr id, mngrname, mngrage,ecity)
b)Student(no,name, bdate, city, semester, subname, submarks, percentage)

Problem Analysis Understanding Timely Mock Total


& Solution Level Completion (2) (10)
(3) (3) (2)

Signature : __________________________

Date : __________________________

Page no____________

You might also like