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

JCS1312 - DBMS Lab Record (21-22)

Here are the steps to create a database and perform DDL, DML and DCL operations: 1. Start SQL*Plus and connect to the database using username and password. 2. Create a database using CREATE DATABASE command. 3. Use the database using USE command. 4. Create a table using CREATE TABLE with column names and data types. 5. Describe the table using DESC command. 6. Insert records into the table using INSERT command. 7. Retrieve records from the table using SELECT command. 8. Update records in the table using UPDATE command. 9. Delete records from the table using DELETE command. 10. Commit or rollback transactions
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)
75 views

JCS1312 - DBMS Lab Record (21-22)

Here are the steps to create a database and perform DDL, DML and DCL operations: 1. Start SQL*Plus and connect to the database using username and password. 2. Create a database using CREATE DATABASE command. 3. Use the database using USE command. 4. Create a table using CREATE TABLE with column names and data types. 5. Describe the table using DESC command. 6. Insert records into the table using INSERT command. 7. Retrieve records from the table using SELECT command. 8. Update records in the table using UPDATE command. 9. Delete records from the table using DELETE command. 10. Commit or rollback transactions
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/ 102

JERUSALEM COLLEGE OF ENGINEERING

(An Autonomous Institution)


(Approved by AICTE, Affiliated to Anna University
Accredited by NBA and NAAC with ‘A’ Grade)
Velachery Main Road, Narayanapuram, Pallikaranai, Chennai – 600 100

DATABASE MANAGEMENT SYSTEMS


LABORATORY
[JCS1312]

RECORD NOTE BOOK


ACADEMIC YEAR 2021 -2022

II YEAR/ III SEMESTER


REGULATION: 2019

DEPARTMENT OF COMPUTER SCIENCE AND


ENGINEERING
Vision of the Department

The Department of computer science and engineering is dedicated to be a center of


excellence, in producing graduates as ethical engineers, innovative researchers, dynamic
entrepreneurs and globally competitive technocrats.
Mission of the Department
 To craft students to be competent professionals with value based education,
innovative teaching and practices.
 To enhance student‘s soft skill, personality and ethical responsibilities by augmenting in-
plant training, value added courses and co curricular activities.
 To facilitate the student as researchers by widening their professional knowledge through
continuous learning and innovative projects.
 To produce dynamic entrepreneur through interaction with network of alumni industry and
academia and extracurricular activities.
Program Educational Objectives (PEOs)

 PEO1:Graduates will apply engineering basics, laboratory and job oriented expe riences to
devise and unravel engineering problems in computer science engineering domain.
 PEO2:Graduates will be multi faceted researcher and experts in fields like computing,
networking, artificial intelligence, software engineering and data science.
 PEO3:Graduates will be dynamic entrepreneur and service oriented professional with ethical
and social responsibility.

 PEO4:Graduates will ingress and endure in core and other prominent organization across the
globe and will foster innovation.

Program Specific Objectives (PSOs)

PSO-I: The ability to understand, analyze and to develop the design related to real-time system
such as IOT, Secured automated systems, machine vision , computer vision and cognitive
computing with various complexities , providing orientation towards green computing
environment .

PSO-II: The ability to apply standard practices and strategies in software project development
using open-ended programming environments to deliver a quality product.

PSO-III: The ability to innovate, introduce and produce socially relevant products to facilitate
transformation of society into a digitally empowered knowledge economy, thereby to chart a
successful career with a new dimension to entrepreneurship.
JERUSALEM COLLEGE OF ENGINEERING
(An Autonomous Institution)
(Approved by AICTE, Affiliated to Anna University
Accredited by NBA and NAAC with ‘A’ Grade)
Velachery Main Road, Narayanapuram,Pallikaranai, Chennai – 600 100

Name……………………………………………………………………………………

Year…………………………………Semester………………Branch……………….

Regulation…………………………….

Register No.

Certified that this is a Bonafide Record work done by the above student in the…………………

…..……………………………………………. Laboratory during the year 20 - 20

Signature of Lab In-charge Signature of Head of the Department

EXAMINERS

DATE:

INTERNAL EXAMINER EXTERNAL EXAMINER


JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

JCS1312 DATABASE MANAGEMENT SYSTEMS L T P C


LABORATORY
0 0 4 2

SYLLABUS

COURSE OBJECTIVES:

1. To familiarize with DDL, DML and DCL Commands


2. To learn the use of nested and join queries
3. To understand functions, procedures and procedural extensions of databases
4. To be familiar with database triggers for specific application
5. To develop applications using front-end tools and back-end DBMS

LIST OF EXPERIMENTS

1.Data Definition Commands, Data Manipulation Commands for inserting, deleting, updating
and retrieving Tables and Transaction Control statements.
2. Database Querying – Simple queries, Nested queries, Sub queries and Joins
3. Creation of Views, Sequences, Indexes, Savepoint and commit constraints
4. Database Programming: Implicit and Explicit Cursors with PL/SQL block
5.Creation of PL/SQL Procedures and Functions
6. Creation of PL/SQL Triggers
7. Exception Handling
8. Database Design using ER modeling, Normalization and Implementation for any
application
9. Database Connectivity with Front End Tools
10. Mini project (Application Development) in one or two of the following systems
a) Student database system
b) Inventory Control System
c) Online Library Management
d) Hospital Management System
e) Railway Reservation System
f) Personal Information System
g) Online Course registration and maintenance System
h) Attendance Management System
i) Hotel Management System
j) E-commerce portal
k) Online auction system

TOTAL :60 PERIODS


JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

COURSE OUTCOMES:

Upon completion of the course, the students will be able to:


1. Execute typical data definitions, data control and data manipulation commands
2. Familiarize with Nested and Join Queries for extracting combinatorial data
3. Implement simple applications that use Views
4. Develop PL/SQL procedures, functions and packages
5. Develop applications using Front-end & Back-end Tools and also to handle report
generation
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

LIST OF EXPERIMENTS
CYCLE 1

S.No NAME OF THE EXPERIMENT


Data Definition Commands, Data Manipulation Commands for inserting,
1
deleting, updating and retrieving Tables and Transaction Control statements.
2 Database Querying – Simple queries, Nested queries, Sub queries and Joins

3 Creation of Views, Sequences, Indexes, Savepoint and commit constraints

4 Database Programming: Implicit and Explicit Cursors with PL/SQL block

5 Creation of PL/SQL Procedures and Functions

CYCLE 2

S.No NAME OF THE EXPERIMENT

7 Creation of PL/SQL Triggers

8 Exception Handling
Database Design using ER modeling, Normalization and Implementation for any
9
application
10 Mini project (Application Development)

ADDITIONAL EXPERIMENTS

S.No NAME OF THE EXPERIMENT

1 Develop an application for Payroll Management

2 Develop an application for Covid vaccination registration and status.


JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

INDEX

Ex.No Date Name of the Experiment Page.No Marks Signature


with date
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

INDEX

Ex.No Date Name of the Experiment Page.No Marks Signature


with date

AverageMarks:

Signature :
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Ex.No:1
DATA DEFINITION COMMANDS, DATA MANIPULATION COMMANDS
FOR INSERTING, DELETING, UPDATING AND RETRIEVING TABLES
Date: AND TRANSACTION CONTROL STATEMENTS.

AIM:

To create a database and execute the SQL Commands for data definition commands, data
manipulation commands for inserting, deleting, updating and retrieving tables and transaction
control statements.

PROCEDURE:
STEP 1: Start

STEP 2: Create a database.

STEP 2: Create the table with its essential attributes.

STEP 3: Execute different Commands and extract information from the table.

STEP 4: Stop

Syntax for creation of database :

CREATE DATABASE DATABASENAME;

USE DATABASENAME;

Syntax for creation of a table:


SQL> CREATE <OBJ.TYPE><OBJ.NAME> (COLUMN NAME.1 <DATATYPE> (SIZE),
COLUMN NAME.2 <DATATYPE> (SIZE) ……………………………);
(or)

SQL> CREATE TABLE <TRAGET TABLE NAME> SELECT EMPNO, ENAME


FROM <SOURCE TABLE NAME>;
(or)
SQL> CREATE TABLE <TRAGET TABLE NAME> AS SELECT * FROM
<SOURCE TABLE NAME> WHERE <FALSE CONDITION>;
Syntax for describing a table:
SQL> DESC <TABLE NAME>;
Syntax :
SQL > INSERT INTO <TABLE NAME> VALUES< VAL1, ‘VAL2’,…..);

Syntax:
SQL> SELECT * FROM <TABLE NAME>;

1
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

2
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

3
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

4
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

5
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

DDL (DATA DEFINITION LANGUAGE)

 DROP
 
TRUNCATE
 
ALTER
 
RENAME

DML (DATA MANIPULATION LANGUAGE)


 INSERT
 
SELECT
 
UPDATE
 
DELETE

PROCEDURE

STEP 1: Start
STEP 2: Create the table with its essential attributes.
STEP 3: Insert the record into table
STEP 4: Update the existing records into the table
STEP 5: Delete the records from the table
STEP 6: Viewing records from database.
STEP 7: Alter and Modify the table.
STEP 8: Stop

SQL COMMANDS:
Syntax :

SQL > INSERT INTO <TABLE NAME> VALUES< VAL1, ‘VAL2’,…..);

(or)
SQL> INSERT INTO <TABLE NAME> VALUES< ‘&column name’, ‘&column name 2’,…..);

Syntax:
SQL> SELECT * FROM <TABLE NAME>;

Syntax:

SQL> UPDATE <<TABLE NAME> SET <COLUMNANE>=<VALUE> WHERE


<COLUMN NAME=<VALUE>;

6
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Syntax for updating multiple Records from the table:

SQL> UPDATE <<TABLE NAME> SET <COLUMNANE>=<VALUE> WHERE


<COLUMN NAME=<VALUE>;

Syntax :
SQL> DELETE <TABLE NAME> WHERE <COLUMN
NAME>=<VALUE>;

Syntax to Alter & Modify on a Single Column:

SQL > ALTER <TABLE NAME> MODIFY <COLUMN NAME><DATATYPE>


(SIZE);

Syntax to alter multiple column:

SQL > ALTER <TABLE NAME> MODIFY <COLUMN NAME1><DATATYPE>


(SIZE), MODIFY <COLUMN NAME2><DATATYPE>
(SIZE)………………………………………….;

Syntax to add a new column:

SQL> ALTER TABLE <TABLE NAME> ADD (<COLUMN NAME><DATA


TYPE><SIZE>);

Syntax for add multiple new columns:

SQL> ALTER TABLE <TABLE NAME> ADD (<COLUMN NAME1><DATA


TYPE><SIZE>,(<COLUMN NAME2><DATA
TYPE><SIZE>,………………………………………………………………);

Syntax :

SQL> ALTER TABLE <TABLE NAME> DROP COLUMN <COLUMN NAME>;


Syntax:

SQL> ALTER TABLE <TABLE NAME> DROP <COLUMN NAME1>,<COLUMN


NAME2>,…………………………….. ;

Syntax:

SQL> ALTER TABLE RENAME <OLD NAME> TO <NEW NAME>;

7
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

8
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

9
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

10
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Result:

11
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Ex.No: 2
DATABASE QUERYING – SIMPLE QUERIES, NESTED QUERIES,
SUB QUERIES AND JOINS
Date:

AIM

To execute and verify the SQL commands for Nested Queries and Join queries.

PROCEDURE

STEP 1: Start

STEP 2: Create two different tables with its essential attributes.

STEP 3: Insert attribute values into the table.

STEP 4: Create the Nested query from the above created table.

STEP 5: Execute Command and extract information from the tables.

STEP 6: Stop

SQL COMMANDS FOR NESTED QUERIES

1. Command Name: SELECT

Command Description: SELECT command is used to select records from the table.

2. Command Name: WHERE

Command Description: WHERE command is used to identify particular elements.

3. Command Name: HAVING

12
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Command Description: HAVING command is used to identify particular elements.

4. Command Name: MIN (SAL)

Command Description: MIN (SAL) command is used to find minimum salary.

GENERAL SYNTAX FOR NESTED QUERY:

SELECT "COLUMN_NAME1"FROM "TABLE_NAME1"WHERE "COLUMN_NAME2"


[COMPARISON OPERATOR](SELECT "COLUMN_NAME3"FROM "TABLE_NAME2"
WHERE [CONDITION])

SYNTAX FOR NESTED QUERY STATEMENT:

SQL> SELECT <COLUMN_NAME> FROM <TABLE _1> WHERE

<COLUMN_NAME><RELATIONAL _OPERATION> ‘VALUE’(SELECT (AGGRECATE


FUNCTION) FROM <TABLE_1> WHERE <COLUMN NAME> = ‘VALUE’(SELECT
<COLUMN_NAME> FROM <TABLE_2> WHERE <COLUMN_NAME= ‘VALUE’));

SQL COMMANDS FOR JOIN QUERIES

1.Command Name: INNER JOIN

Command Description: The INNER JOIN keyword return rows when there is at least one
match in both tables.

2.Command Name: LEFT JOIN

Command Description: The LEFT JOIN keyword returns all rows from the left table
(table_name1), even if there are no matches in the right table (table_name2).

3.Command Name : RIGHT JOIN

13
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Command Description: The RIGHT JOIN keyword Return all rows from the right table
(table_name2), even if there are no matches in the left table (table_name1).

4.Command Name : FULL JOIN

Command Description: The FULL JOIN keyword return rows when there is a match in

one of the tables.

Syntax for left outer join:

SQL> SELECT column_name(s) FROM table_name1LEFT JOIN table_name2 ON


table_name1.column_name = table_name2 .column_name

Syntax for full outer join:

SQL>SELECT column_name(s)FROM table_name1 FULL JOIN


table_name2ON table_name1.column_name=table_name2 column_name.

Syntax for right outer join:


SQL>SELECT column_name(s)FROM table_name1 RIGHT JOIN table_name2 ON
table_name1.column_name=table_name2

Syntax for inner join:

SQL>SELECT column_name(s) FROM table_name1 INNER JOIN


table_name2 ON table_name1.column_name=table_name2.column_name

14
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

15
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

16
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

17
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

18
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

19
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Result:

20
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Ex.No:3
CREATION OF VIEWS, SEQUENCES, INDEXES, SAVEPOINT
AND COMMIT CONSTRAINTS
Date:

AIM:
To execute and verify the SQL commands for Views, Synonyms, Sequence and Indexes.

PROCEDURE:

STEP 1: Start

STEP 2: Create the table with its essential attributes.

STEP 3: Insert attribute values into the table. 

STEP 4: Create the view from the above created table. 

STEP 5: Execute different Commands and extract information from the View. 

STEP 6: Use synonyms to create an alias name for the table. 

STEP 7: Use sequences to order the numbering of records.

STEP 8: Use indexes to speed up the performance. 

STEP 9: Use save point if any changes occur in any portion of the record to undo its original state. 

STEP 10: Use rollback to completely undo the records

STEP 11: Use commit to permanently save the records.

STEP 12: Stop.

VIEWS
1. Command Name: CREATE VIEW

Command Description: CREATE VIEW command is used to define a view.

2. Command Name: INSERT IN VIEW

Command Description: INSERT command is used to insert a new row into the view.

3. Command Name: DELETE IN VIEW


Command Description: DELETE command is used to delete a row from the view.

4. Command Name: UPDATE OF VIEW

Command Description: UPDATE command is used to change a value in a tuple without changing

21
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

all values in the tuple.

a) Command Name: DROP OF VIEW

Command Description: DROP command is used to drop the view table

Syntax for creating a view:

SQL> CREATE <VIEW><VIEW NAME> AS SELECT

<COLUMN_NAME_1>, <COLUMN_NAME_2> FROM <TABLE NAME>;

(or)

SQL>CREATE [OR REPLACE] VIEW <VIEW NAME>AS SELECT <COLUMN


NAME1>…..FROM <TABLE ANME>;

Syntax for inserting into view:

SQL> INSERT INTO <VIEW_NAME> (COLUMN NAME1,…)VALUES(VALUE1,….);

Syntax for deleting a column from a view:

SQL> DELETE <VIEW_NAME>WHERE <COLUMN NAME> =’VALUE’;

Syntax for updating a view:

SQL>UPDATE <VIEW_NAME> SET< COLUMN NAME> = <COLUMN NAME> +<VIEW> WHERE


<COLUMNNAME>=VALUE;

Syntax for deleting a view:

SQL> DROP VIEW <VIEW_NAME>

22
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Syntax for creating a synonym:


SQL>CREATE SYNONYM synonym-name FOR table-name;

Syntax for creating a sequence:


CREATE SEQUENCE sequence_name
MINVALUE value
MAXVALUE value
START WITH value

INCREMENT BY value
CACHE value;

Syntax for creating an index:


CREATE INDEX index_name ON table_name (column_name)

Syntax:
SQL> SAVEPOINT <SAVE POINT NAME>;

Syntax:
SQL> ROLL BACK to <SAVE POINT NAME>;

Syntax:
SQL> COMMIT;

23
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

24
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

25
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

26
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

TYPES OF CONSTRAINTS:
1) Primary key
2) Foreign key/references
3) Check
4) Unique
5) Not null
6) Null
7) Default

CONSTRAINTS CAN BE CREATED IN THREE WAYS:


a) Column level constraints
b) Table level constraints
c) Using DDL statements-alter table command

OPERATION ON CONSTRAINT:
1. ENABLE
2. DISABLE
3. DROP
Primary key
Syntax :

SQL:>CREATE <OBJ.TYPE><OBJ.NAME> (COLUMN NAME.1 <DATATYPE>


(SIZE)<TYPE OF CONSTRAINTS> , COLUMN NAME.1 <DATATYPE>
(SIZE)……………………………);

Reference /foreign key constraint


Parent Table:

Syntax for Column level constraints Using Primary key:

SQL:>CREATE <OBJ.TYPE><OBJ.NAME> (COLUMN NAME.1 <DATATYPE>


(SIZE)<TYPE OF CONSTRAINTS> , COLUMN NAME.1 <DATATYPE>
(SIZE)……………………………);

27
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Child Table:
Syntax for Column level constraints Using foreign key:

SQL:>CREATE <OBJ.TYPE><OBJ.NAME> (COLUMN NAME.1 <DATATYPE> (SIZE),


COLUMN NAME2 <DATATYPE> (SIZE) REFERENCES <TABLE NAME>(COLUMN
NAME> ……………………………);

Check constraint

Syntax for column level constraints using Check:

SQL:>CREATE <OBJ.TYPE><OBJ.NAME> (COLUMN NAME.1 <DATATYPE> (SIZE)


CONSTRAINT <CONSTRAINTS NAME><TYPE OF CONSTRAINTS> (CONSTRAITNS
CRITERIA) , COLUMN NAME2 <DATATYPE> (SIZE));

Unique Constraint

Syntax for Column level constraints with Unique:

SQL :> CREATE <OBJ.TYPE><OBJ.NAME> (<COLUMN


NAME.1><DATATYPE> (SIZE) CONSTRAINT <NAME OF
CONSTRAINTS><CONSTRAINT TYPE>, (COLUMN NAME2 <DATATYPE>
(SIZE)) ;

Not Null Constraint

Syntax for Column level constraints with Not Null:

SQL :> CREATE <OBJ.TYPE><OBJ.NAME> (<COLUMN


NAME.1><DATATYPE> (SIZE) CONSTRAINT <NAME OF
CONSTRAINTS><CONSTRAINT TYPE>, (COLUMN NAME2 <DATATYPE>
(SIZE)) ;

28
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Null Constraint

Syntax for Column level constraints with Null:

SQL :> CREATE <OBJ.TYPE><OBJ.NAME> (<COLUMN


NAME.1><DATATYPE> (SIZE) CONSTRAINT <NAME OF
CONSTRAINTS><CONSTRAINT TYPE>, (COLUMN NAME2 <DATATYPE>
(SIZE)) ;

Constraint Disable \ Enable


Syntax for enabling/disabling a single constraint in a table:

SQL>ALTER TABLE <TABLE-NAME> ENABLE/DISABLE CONSTRAINT


<CONSTRAINT-NAME>

29
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

30
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Result:

31
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Ex.No:4 DATABASE PROGRAMMING: IMPLICIT AND EXPLICIT


CURSORS WITH PL/SQL BLOCK
Date:

Aim:
To write PL/SQL block to satisfy some condition by accepting input from user

Algorithm:

STEP 1: Start

STEP 2: Create the table with essential attributes.

STEP 3: Initialize the Function to carryout the searching procedure..

STEP 4: Frame the searching procedure for both positive and negative searching.

STEP 5: Execute the Function for both positive and negative result .

STEP 6: Stop

Program:

mysql>DELIMITER $$
mysql>CREATE FUNCTION F_ADD(A INTEGER, B INTEGER)
RETURNS INTEGER
BEGIN
DECLARE C INTEGER;
SET C=A+B;
RETURN C;
END;

Output:

mysql>select F_ADD(2000,2222);

+ ------------------ +
| F_ADD(45,56) |
+ ------------------ +
| 101 |
+ ------------------ +
1 rows

32
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Function 2:
Greatest of three numbers
delimiter $$
CREATE FUNCTIONgreatestofthree(A INTEGER, B INTEGER, C integer)
RETURNS INTEGER
BEGIN
if A>B and A>C then
return A;
elseif B>A and B>C then
return B;
else
return C;
end if;
END;
$$

Output:
mysql> select greatestofthree(10,25,5)

+ ----------------------------- +
| greatestofthree(10,25,5) |
+ ----------------------------- +
| 25 |
+ ----------------------------- +
1 rows

Simple intrest:

DELIMITER $$
CREATE FUNCTION pnr101(p float, n float, r FLOAT)
RETURNS float
BEGIN
declarepnr float;
setpnr=p* n* r;
returnpnr/100;
END;

Output:

mysql> select pnr1011(10.5,15.2,20.3)


+ ---------------------------- +
| pnr1011(10.5,15.2,20.3) |
+ ---------------------------- +
| 32.398799896240234 |

33
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

+ ---------------------------- +
1 rows

Result:

34
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Ex.No: 5
CREATION OF PL/SQL PROCEDURES AND FUNCTIONS

Date:

Aim:
To create procedure and functions in mysql

Procedure - Syntax:
Create procedure <procedure name>
Begin
<Statements>;
End;

Procedure 1:

mysql>delimiter ///
mysql>CREATE PROCEDURE Student()
BEGIN
SELECT studid,studname,gender,percentage
FROM Student s
WHERE percentage > 90;
END;
///

Output:

mysql>call student;

Procedure 2:
Cursor:

mysql>delimiter $$
mysql>create procedure proname1111()
begin
declarev_empidint(10);

35
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

declarev_empnamevarchar(10);
declare c cursor for select empid,empname from employee WHERE departmentid=102;
OPEN C;
loop1:loop
FETCH C INTO v_empid, v_empname ;
selectv_empid , v_empname;
end loop loop1;
close c;
end;
delimiter $$;

output:

mysql> call proname1111()

Functions
Syntax:

mysql>Delimiter///
Create function fn_name(param1,Param2…)
returnsdatatype
<function_body>
///
delimiter ;

Function1:

mysql>Delimiter ///
mysql>CREATE FUNCTION getBal(v_custid integer)
RETURNS FLOAT
BEGIN

DECLARE V_BAL FLOAT;


BEGIN
SELECT SUM(A.ACCBAL)
INTO V_BAL
FROM ACCOUNT A
WHERE A.CUSTID = V_CUSTID;
END;
RETURN V_BAL;
END;
///

Output:
selectgetbal(123);

36
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

2)write a function mysql to calculate the factorial of a given no.

mysql> delimiter //
mysql> create function fact(n int)

returns integer
begin
declarefacint;
declareiint;
setfac = 1;
seti = 1;

myloop : loop
ifi> n then
leavemyloop;
else
setfac = fac * i;
seti = i + 1;

iteratemyloop;
end if;
end loop;
return (fac);
end
//

Output:
Query OK, 0 rows affected (0.00 sec)

mysql> select fact(3);


//

37
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

3)write a function in mysql to calculate the sum of fibonacci series.

mysql> delimiter //
mysql> create function sum_fb(n int)
returnsint
begin

declare a int;
declare b int;
declare c int;
declare s int;
declareiint;
set a = 0;

set b = 1;
seti = 3;
set s = 1;
myloop : loop
ifi> n then
leave myloop;

else
set c = a + b;
set a = b;
set b = c;
set s = s + c;
seti = i + 1;

iterate myloop;
end if;

38
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

end loop;
return s;
end
//

Output:

Query OK, 0 rows affected (0.05 sec)

mysql> select sum_fb(3);


-> //

4)write a function in mysql to print 'hello yourname how are you'

mysql> delimiter //
mysql> create function print_name(name varchar(25))
returns varchar(50)
begin
returnconcat('Hello',' ',name,' ','how are you.');

end;
//

Output:
Query OK, 0 rows affected (0.05 sec)

mysql> select print_name('janai');


-> //

Result:

39
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Ex.No:6
CREATION OF PL/SQL TRIGGERS

Date:

Aim:
To create database triggers using mysql

Triggers - Syntax:

delimiter ///
CREATE TRIGGER <trigger_name><trigger_time><trigger_event> ON <table_name>
FOR EACH ROW
<trigger_body>
///
delimiter ;

Trigger1 After Insert:

mysql>create table foo1 (a INT, b INT, ts TIMESTAMP);


mysql>create table bar1 (a INT, b INT);

mysql>INSERT INTO foo1 (a,b) VALUES(1,1);


mysql>INSERT INTO foo1 (a,b) VALUES(2,2);
mysql>INSERT INTO foo1 (a,b) VALUES(6,6);

mysql>select * from foo1;

mysql>delimiter ///
CREATE TRIGGER ins_sum11 AFTER insert ON foo1
FOR EACH ROW
BEGIN

INSERT INTO bar1 (a, b) VALUES(NEW.a, NEW.b);


END;
///
mysql> delimiter ;
mysql>desc foo;
mysql> update foo set a=20 where b=1;
mysql>select * from bar1;

40
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Result:

41
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Ex.No: 7
EXCEPTION HANDLING
Date:

Aim:
To write a PL/SQL block to handle different types of exception

Program:

(1) Exception handling for ‘No data found’

DELIMITER $$

CREATE PROCEDURE `Student_check`(IN STID INTEGER)


BEGIN
BEGIN
SELECT studid,studname,gender,percentage
FROM Student s
WHERE studid= STID;
END;
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='NO DATA FOUND';
END

Output:

CALL Student_check(21);
No data found

(2) Exception handling for ‘No data found’

DELIMITER $$

CREATE PROCEDURE `Student_exist`(IN STID INTEGER)


BEGIN
declarev_stdid integer;
BEGIN
SELECT studid
intov_stdid
FROM Student s
WHERE studid= STID;
END;

42
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

ifv_stdid is null then


SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='NO DATA FOUND';
else
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='DATA FOUND';
end if;
END

Output:
CALL Student_exist(21);
No data found
CALL Student_exist(201);
Data found

(3) Exception handling for ‘Divide by zero’

DELIMITER $$

CREATE PROCEDURE `div_by_zero`(IN A INTEGER,IN B INTEGER)


BEGIN
DECLARE C INTEGER;
declarediv_by_zero condition for sqlstate '22012';

declare CONTINUE handler for div_by_zero


RESIGNAL SET MESSAGE_TEXT='DIVISION BY ZER0 ERROR';

IF B=0 THEN
SIGNAL div_by_zero;
END IF;
END

Output:
mysql>CALL div_by_zero(1,1);
mysql>CALL div_by_zero(0,1);
Division by zero error.

43
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

(4) Exception handling for ‘reporting duplicate key values’

DELIMITER $$

CREATE PROCEDURE `insert_account`(in v_Accd integer,


v_Accbal integer,
v_Custid integer)
BEGIN

declare continue handler for 1062


select 'duplicate primary key found';

insert into account(Accd,Accbal,Custid) values(v_Accd,v_Accbal,v_Custid);


commit;
END

Output:

mysql>call insert_account(111,1000,123444);
Duplicate primary key found.

(5) Exception handling for ‘No data found’

DELIMITER $$

CREATE PROCEDURE `Student_exist_exception`(IN STID INTEGER)


BEGIN
declarev_stdid integer;
declare continue handler for not found
select 'NO DATA FOUND';
BEGIN
SELECT studid
intov_stdid
FROM Student s
WHERE studid= STID;
END;
END

Output:
mysql>CALL Student_exist_exception(21);
No data found

44
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Result:

45
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Ex.No:8
DATABASE DESIGN USING ER MODELING,
NORMALIZATION AND IMPLEMENTATION FOR ANY
Date:
APPLICATION

Aim:
To design Database using ER modelling and implement normalization

What is ER Modeling?
Entity Relationship Modeling (ER Modeling) is a graphical approach to database design. It uses
Entity/Relationship to represent real world objects.

An Entity is a thing or object in real world that is distinguishable from surrounding environment. For
example each employee of an organization is a separate entity. Following are some of major characteristics
of entities.

 An entity has a set of properties.


 Entity properties can have values.

Enhanced Entity Relationship (EER) Model


Enhanced Entity Relationship (EER) Model is a high level data model which provides extensions to
original Entity Relationship (ER) model. EER Models supports more details design. EER Modeling
emerged as a solution for modeling highly complex databases.

EER uses UML notation. UML is the acronym for Unified Modeling Language; it is a general purpose
modeling language used when designing object oriented systems. Entities are represented as class
diagrams. Relationships are represented as associations between entities. The diagram shown below
illustrates an ER diagram using the UML notation.

46
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Study: ER diagram for "MyFlix" Video Library

Let's now work with the MyFlix Video Library database system to help understand the concept of ER
diagrams. We will using this database for all hand-on in the remainder of this tutorials
MyFlix is a business entity that rents out movies to its members. MyFlix has been storing its records
manually. The management now wants to move to a DBMS
Let's look at the steps to develop EER diagram for this database-
1. Identify the entities and determine the relationships that exist among them.
2. Each entity, attribute and relationship, should have appropriate names that can be easilyunderstood
by the non-technical people as well.
3. Relationships should not be connected directly to eachother. Relationships should connect entities.
4. Each attribute in a given entity should have a unique name.

Entities in the "MyFlix" library


The entities to be included in our ER diagram are;
Members - this entity will hold member information.
Movies - this entity will hold information regarding movies
Categories - this entity will hold information that places movies into different categories suchas
"Drama", "Action", and "Epic" etc.
Movie Rentals - this entity will hold information that about movies rented out to members.
Payments - this entity will hold information about the payments made by members.

Defining the relationships among entitiesMembers and movies

The following holds true regarding the interactions between the two entities.
A member can rent a more than movie in a given period.
A movie can be rented by more than one member in a given period.
From the above scenario, we can see that the nature of the relationship is many-to-many. Relational
databases do not support many-to-many relationships. We need to introduce a junction entity. This
is the role that the MovieRentals entity plays. It has a one-to-many relationship with the members table
and another one-to-many relationship with movies table.

Movies and categories entities


The following holds true about movies and categories.
A movie can only belong to one category but a category can have more than one movie.
We can deduce from this that the nature of the relation between categories and movies table is one-to-
many.

Members and payments entities


The following holds true about members and payments
A member can only have one account but can make a number of payments.

47
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

We can deduce from this that the nature of the relationship between members and payments entities is
one-to-many.
Now lets create EER model using MySQL WorkbenchIn the MySQL workbench , Click - "+" Button

Double click on Add Diagram button to open the workspace for ER diagrams

48
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Following window appears

Let's look at the two objects that we will work with.

The table object allows us to create entities and define the attributes associated with theparticular
entity.

The place relationship button allows us to define relationships between entities.

The members' entity will have the following attributes


 Membership number
 Full names
 Gender
 Date of birth
 Physical address
 Postal address
Let's now create the members table
1. Drag the table object from the tools panel
2. Drop it in the workspace area. An entity named table 1 appears 3.Double click on it. The properties
window shown below appears

49
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Next ,
1. Change table 1 to Members
2. Edit the default idtable1 to membership_number
3. Click on the next line to add the next field
4. Do the same for all the attributes identified in members' entity.
Your properties window should now look like this.

Repeat the above steps for all the identified entities.


Your diagram workspace should now look like the one shown below.

50
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Lets create relationship between Members and Movie Rentals

1. Select the place relationship using existing columns too


2. Click on membership_number in the Members table
3. Click on reference_number in the MovieRentals table

Repeat above steps for other relationships. Your ER diagram should now look like this -

What is Normalization? 1NF, 2NF, 3NF & BCNF with ExamplesWhat is Normalization?

Normalization is a database design technique which organizes tables in a manner that reduces
redundancy and dependency of data.

It divides larger tables to smaller tables and links them using relationships.
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

The evolution of Normalization theories is illustrated below-

Database Normalization Examples -

Assume a video library maintains a database of movies rented out. Without any normalization, all
information is stored in one table as shown below.

Here you see Movies Rented column has multiple values. Database Normal Forms

Now let's move into 1st Normal Forms

1NF (First Normal Form) Rules

 Each table cell should contain a single value.


 Each record needs to be unique.

The above table in 1NF-


1NF Example

Table 1: In 1NF Form


JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Before we proceed let's understand a few things --


What is a KEY?

A KEY is a value used to identify a record in a table uniquely. A KEY could be a single column
orcombination of multiple columns
Note: Columns in a table that are NOT used to identify a record uniquely are called non-key

columns. What is a Primary Key?

A primary is a single column value used to identify a database recorduniquely.

It has following attributes


 A primary key cannot be NULL
 A primary key value must be unique
 The primary key values cannot be changed
 The primary key must be given a value when a new record is inserted.
What is Composite Key?
A composite key is a primary key composed of multiple columns used to identify a record
uniquely
In our database, we have two people with the same name Robert Phil, but they live in
different places.

Hence, we require both Full Name and Address to identify a record uniquely. That is a
compositekey.
2NF (Second Normal Form) Rules
 Rule 1- Be in 1NF
 Rule 2- Single Column Primary Key
It is clear that we can't move forward to make our simple database in 2nd Normalization form
unlesswe partition the table above.
Table 1
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Table 2
We have divided our 1NF table into two tables viz. Table 1 and Table2. Table 1 contains
member information. Table 2 contains information on movies rented.We have introduced a new
column called Membership_id which is the primary key for table 1. Records can be uniquely
identified in Table 1 using membership id
Database - Foreign Key

In Table 2, Membership_ID is the Foreign Key

Foreign Key references the primary key of another Table! Ithelps connect your Tables
 A foreign key can have a different name from itsprimary key
 It ensures rows in one table have corresponding rows inanother
 Unlike the Primary key, they do not have to be unique. Most often they aren't
 Foreign keys can be null even though primary keys cannot
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Why do you need a foreign key?


Suppose an idiot inserts a record in Table B such as You will only be able to insert values into
your foreign key that exist in the unique key in the parenttable. This helps in referential integrity.

The above problem can be overcome by declaring membership id from Table2 as foreign key
ofmembership id from Table1

Now, if somebody tries to insert a value in the membership id field that does not exist in the
parenttable, an error will be shown!
What are transitive functional dependencies?

A transitive functional dependency is when changing a non-key column, might cause any of the
other non-key columns to change

Consider the table 1. Changing the non-key column Full Name may change Salutation.

Let's move into 3NF


3NF (Third Normal Form) Rules
 Rule 1- Be in 2NF
 Rule 2- Has no transitive functional dependencies
To move our 2NF table into 3NF, we again need to again divide our table.
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

3NF Example

TABLE 1

Table 2

Table 3
We have again divided our tables and created a new table which stores Salutations.
There are no transitive functional dependencies, and hence our table is in 3NF
In Table 3 Salutation ID is primary key, and in Table 1 Salutation ID is foreign to primary
key inTable 3
Now our little example is at a level that cannot further be decomposed to attain higher forms of
normalization. In fact, it is already in higher normalization forms. Separate efforts for moving into
next levels of normalizing data are normally needed in complex databases. However, we will be
discussing next levels of normalizations in brief in the following.
Boyce-Codd Normal Form (BCNF)
Even when a database is in 3rd Normal Form, still there would be anomalies resulted if it has more
than one Candidate Key.Sometimes is BCNF is also referred as 3.5 Normal Form.
4NF (Fourth Normal Form) Rules
If no database table instance contains two or more, independent and multivalued data describing
therelevant entity, then it is in 4th Normal Form.
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

5NF (Fifth Normal Form) Rules


A table is in 5th Normal Form only if it is in 4NF and it cannot be decomposed into any number of
smaller tables without loss of data.
6NF (Sixth Normal Form) Proposed
6th Normal Form is not standardized, yet however, it is being discussed by database experts for some
time. Hopefully, we would have a clear & standardized definition for 6 th Normal Form in the near
future...

PROJECT TITLE :
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Result:
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Ex.No:9
DATABASE CONNECTIVITY WITH FRONT END TOOLS

Date:

AIM
To perform database connectivity with front end tools

PROCEDURE

STEP 1: Start

STEP 2: Create the form with essential controls in tool box.

STEP 3: Write the code for doing the appropriate functions.

STEP 4: Save the forms and project.

STEP 5: Execute the form.

STEP 6: Stop

EXECUTION

Code for Dialog Menu:


Private Sub OKButton_Click()
If (Option1.Value = True) Then
SDI.Show
Unload Me
Else

MDIForm1.Show

Unload Me
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

End If
End Sub

Code for MDI Menu:


Private Sub ADD_Click()

MDIADD.Show
End Sub
Private Sub DIV_Click()
MDIDIV.Show
End Sub
Private Sub EXIT_Click()

End
End Sub
Private Sub MUL_Click()
MDIMUL.Show
End Sub
Private Sub SUB_Click()

MDISUB.Show
End Sub

Code for MDI ADD:


Private Sub Command1_Click()
Dim a As Integer
a = Val(Text1.Text) + Val(Text2.Text)
MsgBox ("Addition of Two numbers is" + Str(a))
End Sub

Private Sub Command5_Click()


MDIForm1.Show
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

End Sub

Code for MDI DIV:


Private Sub Command1_Click()
Dim a As Integer

a = Val(Text1.Text) / Val(Text2.Text)
MsgBox ("Addition of Two numbers is" + Str(a))
End Sub
Private Sub Command5_Click()
MDIForm1.Show

End Sub

Code for MDI MUL:


Private Sub Command1_Click()
Dim a As Integer
a = Val(Text1.Text) * Val(Text2.Text)
MsgBox ("Addition of Two numbers is" + Str(a))
End Sub
Private Sub Command5_Click()

MDIForm1.Show
End Sub

Code for MDI SUB:


Private Sub Command1_Click()
Dim a As Integer
a = Val(Text1.Text) - Val(Text2.Text)
MsgBox ("Addition of Two numbers is" + Str(a))
End Sub
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Private Sub Command5_Click()


MDIForm1.Show
End Sub

Code for SDI MENU:


Private Sub Command1_Click()
SDIADD.Show
End Sub
Private Sub Command2_Click()
SDIMUL.Show

End Sub
Private Sub Command3_Click()
SDIDIV.Show
End Sub
Private Sub Command4_Click()
SDISUB.Show

End Sub
Private Sub Command5_Click()
Dialog.Show
Unload Me

End Sub

Code for SDI ADD:


Private Sub Command1_Click()

Dim a As Integer
a = Val(Text1.Text) + Val(Text2.Text)
MsgBox ("Addition of Two numbers is" + Str(a))
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Unload Me
End Sub
Private Sub Command5_Click()
SDI.Show

Unload Me
End Sub

Code for SDI DIV:


Private Sub Command2_Click()
a = Val(Text1.Text) / Val(Text2.Text)
MsgBox ("Addition of Two numbers is" + Str(a))
Unload Me
End Sub

Private Sub Command5_Click()


SDI.Show
Unload Me
End Sub

Code for SDI MUL:


Private Sub Command2_Click()

a = Val(Text1.Text) * Val(Text2.Text)
MsgBox ("Addition of Two numbers is" + Str(a))
Unload Me
End Sub
Private Sub Command5_Click()
SDI.Show
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Unload Me
End Sub

Code for SDI SUB:


Private Sub Command2_Click()

a = Val(Text1.Text) - Val(Text2.Text)
MsgBox ("Addition of Two numbers is" + Str(a))

Unload Me
End Sub

Private Sub Command5_Click()


SDI.Show

Unload Me
End Sub

Output:
SDI MDI MENU:

SDI MENU:
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

SDI ADDITION:

MDI MENU:

MDI ADD:
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

MDI SUB:

MDI MUL:

MDI DIV
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

MENU DESIGN
To design a Note Pad Application menu using Visual Basic.

Coding:
Private Sub ab_Click()

RichTextBox1.SelFontName = "Arial Black"


End Sub

Private Sub al_Click()


End Sub
Private Sub bold_Click()
RichTextBox1.SelBold = True
End Sub

Private Sub cb_Click()


RichTextBox1.SelColor = vbblue
End Sub

Private Sub cl_Click()

RichTextBox1.SelColor = vbred
End Sub

Private Sub copy_Click()


'Clipboard.SetText "richtextbox1.seltext", 1
'MsgBoxClipboard.GetText

Clipboard.SetText RichTextBox1.SelText, 1
RichTextBox1.SelText = Clipboard.GetText
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

MsgBoxClipboard.GetText
End Sub

Private Sub eighteen_Click()

RichTextBox1.SelFontSize = 18
End Sub

Private Sub exit_Click()

End
End Sub
Private Sub fcg_Click()
RichTextBox1.SelColor = vbgreen
End Sub

Private Sub fourteen_Click()

RichTextBox1.SelFontSize = 14
End Sub

Private Sub helpp_Click()


ans = MsgBox("visual basic sample notepad .....!", vbYes + vbinforamtion, "Help")
If ans = vbYes Then

Unload Me
End If
End Sub

Private Sub italic_Click()


JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

RichTextBox1.SelItalic = True

End Sub

Private Sub MC_Click()

RichTextBox1.SelFontName = "Monotype Corsiva"


End Sub

Private Sub new_Click()


RichTextBox1 = ""
End Sub

Private Sub open_Click()


RichTextBox1.LoadFile ("C:\Notepad\Document.rtf")
End Sub

Private Sub paste_Click()


RichTextBox1.SelText = Clipboard.GetText

End Sub

Private Sub save_Click()


RichTextBox1.SaveFile ("C:\Notepad\Document.rtf")
End Sub

Private Sub sixteen_Click()


RichTextBox1.SelFontSize = 16
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

End Sub
Private Sub Th_Click()
RichTextBox1.SelFontName = "Tahoma"
End Sub

Private Sub tn_Click()


RichTextBox1.SelFontName = "Times New Roman"
End Sub

Private Sub twele_Click()

RichTextBox1.SelFontSize = 12
End Sub
Private Sub underline_Click()
RichTextBox1.SelUnderline = True
End Sub

Private Sub vbblue_Click()


RichTextBox1.SelColor = vbblue
End Sub

Private Sub vbgreen_Click()

RichTextBox1.SelColor = vbgreen
End Sub
Private Sub vbred_Click()
RichTextBox1.SelColor = vbred
End Sub
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Output:
File Menu:

Fig.1. File Menu

Edit Menu

Fig.2. Edit Menu


JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Format Menu:

Fig.3. Format Menu

REPORT DESIGN

Code for progress bar:

Private Sub Form_KeyPress(KeyAscii As Integer)

Unload Me

End Sub

Private Sub Frame1_Click()

Unload Me

frmLogin.Show

End Sub

Private Sub Timer1_Timer()


JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

On Error Resume Next

ProgressBar1.Value = ProgressBar1.Value + 1

If ProgressBar1.Value = 100 Then


login.Show

Unload Me

End If

End Sub

Private Sub Timer2_Timer()

On Error Resume Next

ProgressBar2.Value = ProgressBar2.Value + 1

If ProgressBar2.Value = 100 Then

MsgBox ("welcome")

login.Show

Unload Me

End If

End Sub

Code for login form:

Private Sub Command1_Click()

If (LCase(Text1.Text)) = "nagraaj" And (LCase(Text2.Text)) = "nagraaj" Then


Unload Me

Stock.Show

Else

MsgBox "Please Enter Correct Username and Password"

End If
End Sub
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Private Sub Command2_Click()


End
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If (LCase(Text1.Text)) = "nagraaj" And (LCase(Text2.Text)) = "nagraaj" Then
frmDataEnv.Show
Unload Me
End If
End Sub

Stock Form:
Private Sub cmadd_Click(Index As Integer)

Adodc1.Recordset.AddNew

a = InputBox("ENTER THE PRODUCT CODE")

Text1.Text = a

B = InputBox("ENTER THE PRODUCT NAME")

Text2.Text = B

C = InputBox("ENTER THE MAKE")

Text3.Text = C

D = InputBox("ENTER SUPPLIER")

Text4.Text = D

e = InputBox("ENTER THE QUANTITY")

Text5.Text = e

F = InputBox("ENTER THE PURCHASE DATE")

Text6.Text = F
G = InputBox("ENTER THE PRICE")

Text7.Text = G

H = InputBox("ENTER THE VAT %")


JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Text8.Text = H

Text8.Text = Val(Text7.Text) / 14

Text9.SetFocus

Text9.Text = Val(Text7.Text) + Val(Text8.Text)

'Adodc1.Recordset.Save

'MsgBox ("UPDATED")
End Sub
Private Sub cmddelete_Click(Index As Integer)
Dim s As String
a = InputBox("Enter The product name")
a = Trim(a)
s = "product_TNAME='" & a '" "
Adodc1.Recordset.Delete
MsgBox ("deleted")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
End Sub
Private Sub cmdmovl_Click(Index As Integer)
Adodc1.Recordset.MoveNext
End Sub

Private Sub cmdmovn_Click(Index As Integer)

'dodc1.Recordset.MoveNext

If (Adodc1.Recordset.EOF) = True Then

Adodc1.Recordset.MoveNext

Else

Adodc1.Recordset.MovePrevious
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

MsgBox ("THIS IS YOUR LAST RECORD")

End If

End Sub

Private Sub cmdmovp_Click(Index As Integer)

'dodc1.Recordset.MovePrevious

If Adodc1.Recordset.BOF = True Then

Adodc1.Recordset.MoveFirst

Else '

Adodc1.Recordset.MoveNext

MsgBox ("THISIS YOUR FIRST RECORD")

End If

End Sub

Private Sub cmdsearch_Click(Index As Integer)

Dim a As String

a = InputBox("Enter Item Code")

s = "Item_code = '" + a + "'"

Adodc1.Recordset.MoveFirst

Adodc1.Recordset.Find s

If Adodc1.Recordset.EOF Then

MsgBox ("INVALID RECORD")

End If

End Sub

Private Sub cmdupadte_Click(Index As Integer)

Adodc1.Recordset.Update
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

MsgBox ("UPDATED")

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

Text7.Text = ""

Text8.Text = ""
Text9.Text = ""

End Sub

Private Sub commov_Click(Index As Integer)

Adodc1.Recordset.MoveFirst

End Sub

Private Sub Command1_Click()

Dim a As String

a = InputBox("Enter Item Code")

s = "Item_code = '" + a + "'"

Adodc1.Recordset.MoveFirst

Adodc1.Recordset.Find s

'Adodc1.Recordset ("select * from t1 where [ITEM_CODE] = " &Text1.Text(0) & "")


DataReport1.Show

If Adodc1.Recordset.EOF Then

MsgBox ("INVALID RECORD")


JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

End If

End Sub

Private Sub Command2_Click()

Adodc1.Recordset.Update

MsgBox ("UPDATED SUCCESSFULY")

End Sub

Private Sub Command3_Click()

Dim s As String

a = InputBox("Enter The student name")

a = Trim(a)

s = "STUDENTNAME='" & a '" "

Adodc1.Recordset.Delete

MsgBox ("deleted")

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

Text7.Text = ""

Text8.Text = ""

Text9.Text = ""

End Sub

Private Sub Command5_Click()


JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

DataReport1.Show

End Sub

Private Sub EXIT_Click()

End

End Sub

Private Sub Image2_Click()

'Adodc1.Recordset (" * from t1 where [ITEM_CODE] = " &Text1.Text(0) & "")


DataReport1.Show

End Sub

Private Sub MSHFlexGrid1_Click()

'Adodc2.Refresh

End Sub

Private Sub VIEW_Click()

DataReport1.Show

End Sub

Output:
Progress Bar
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Login

Stock Form:
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Report Design:

Result:
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Ex.No:10
MINI PROJECT (APPLICATION DEVELOPMENT)
Date:
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Result :
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

ADDITIONAL EXPERIMENTS

Ex.No:1
DEVELOP AN APPLICATION FOR PAYROLL
MANAGEMENT
Date:
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Result:
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Ex.No:2 DEVELOP AN APPLICATION FOR PAYROLL


MANAGEMENT COVID VACCINATION REGISTRATION
Date: AND STATUS.
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22
JCS1312 DBMS LAB DEPARTMENT OF CSE 2021-22

Result:

You might also like