Dbms Lab Manual
Dbms Lab Manual
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: / /
OBJECTIVES:
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.
EXERCISES:
1. Explain current trends, architecture and tools in database .
Signature : __________________________
Date : __________________________
Page no____________
Experiment No: 2 Date: / /
TITLE: Draw ER-Diagram for Banking Management System and convert it relational
schema
OBJECTIVES:
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.
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”
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.
Syntax
INSERT INTO <tablename> (<columnname1> <columnname2>)VALUES (<expression1>
, < expression2>);
Page no____________
Selected rows and all columns
● SELECT * 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.
Signature : __________________________
Date : __________________________
Page no____________
Experiment No: 4 Date: / /
TITLE: Write SQL queries to use Update, alter, rename, delete, truncate and distinct.
OBJECTIVES:
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.
MODIFY(<ColumnName> <NewDataType>(<NewSize>));
Rename the table
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
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.
Signature : __________________________
Date : __________________________
Page no____________
Experiment No: 5 Date: / /
TITLE: Write SQL queries to use various date functions, numeric functions, character
functions, conversion functions.
OBJECTIVES:
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.
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:
THEORY:-
Signature : __________________________
Date : __________________________
Page no____________
Experiment No: 7 Date: / /
OBJECTIVES:
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.
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:
THEORY:
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.
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:
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:
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)
Signature : __________________________
Date : __________________________
Page no____________