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

CS8481 DBMS Lab Manual

The document describes database management system laboratory procedures involving data definition commands like create, alter, drop and truncate table. It also covers data manipulation commands like insert, select, update and delete and transaction control commands like commit and rollback. Step-by-step examples are provided to demonstrate creating a table, inserting data, updating, deleting and dropping records from the table.

Uploaded by

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

CS8481 DBMS Lab Manual

The document describes database management system laboratory procedures involving data definition commands like create, alter, drop and truncate table. It also covers data manipulation commands like insert, select, update and delete and transaction control commands like commit and rollback. Step-by-step examples are provided to demonstrate creating a table, inserting data, updating, deleting and dropping records from the table.

Uploaded by

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

CS8481 DATABASE MANAGEMENT SYSTEMS LABORATORY

EX.NO:1.a DATA DEFINITION COMMANDS


AIM:

PROCEDURE:
 DDL is used to create an object, alter the structure of an object and also drop the already
created object.
 DDL commands are create table, alter table, truncate table, drop table.
a. Create Table: It is used to create a table with a certain fields.
Syntax: create table tablename (field1 dataype1, field2 datatype,….);
b. Alter Table: It is used to add or delete or update a field from the table.
Syntax: To add a field: alter table tablename add field name data type;
Syntax: To drop a field: alter table tablename drop Column field name;
Syntax: To modify the data type: alter table tablename modify field name data typ;
c. Truncate table: It is used to delete the records from table
Syntax: truncate table tablename
d. Drop table: It is used to delete the table
Syntax: drop table tablename;
OUTPUT:
1. CREATE COMMAND
SQL> create table student(sname varchar(10),reg_no number,dept varchar(10));
Table created.
SQL> desc student;
Name Null? Type
------------------------------- -------- -----------
SNAME VARCHAR2(10)
REG_NO NUMBER
DEPT VARCHAR2(10)
2. ALTER COMMAND
SQL> alter table student add mark number;
Table altered.
SQL> desc student;
Name Null? Type
------------------------------- -------- ----
SNAME VARCHAR2(10)
REG_NO NUMBER
DEPT VARCHAR2(10)
MARK NUMBER
3. DROP COMMAND
SQL> alter table student drop column mark;
Table altered.
4. MODIFY COMMAND
SQL> alter table student modify dept varchar(20);
Table altered.
INSERT SOME VALUES
SQL> insert into student values('surya',111,'cse');
1 row created.
SQL> insert into student values('selva',222,'eee');
1 row created.
SQL> select * from student;
SNAME REG_NO DEPT
---------- --------- --------------------
surya 111 cse
selva 222 eee
5. TRUNCATE COMMAND
SQL> truncate table student;
Table truncated.
6. DROP COMMAND
SQL> drop table student;
Table dropped

Result:
EX.NO:1.b DATA MANIPULATION AND TRANSACTION CONTROL
STATEMENTS
AIM:

PROCEDURE:
 DML are used to query and manipulate the existing objects like tables.
 DML commands are insert, delete, update and select.
a. Insert Command: It is used to insert records into the table.
Syntax: insert into table name values (values,……);
b. Select Command: It is used to display the records from the table with satisfies the condition.
Syntax: select * from tabl ename where condition;
c. Update Command: It is used to update the records which are already present in the tables.
Syntax: update table name set fieldname=value where condition;
d. Delete Command: It is used to delete the records from the table with some condition.
Syntax: delete from table name where condition;
TCL commands are
a) Commit: It is used to make changes done in transaction permanent.
Syntax: commit [work] [comment ‘your comment’];
b) Rollback : It is used to rollbacks the state of database to the last commit point.
Syntax:
c) Savepoint : It is used to specify a point in transaction to which later can rollback.
Syntax:
OUTPUT:
SQL> create table student_info(reg_no number(6),name varchar2(40),mark1 number(6),
mark2 number(6));
Table created.
SQL> alter table student_info add(mark3 number(6));
Table altered.
SQL> desc student_info;
Name Null? Type
------------------------------- -------- ----------
REG_NO NUMBER(6)
NAME VARCHAR2(40)
MARK1 NUMBER(6)
MARK2 NUMBER(6)
MARK3 NUMBER(6)
SQL> insert into student_info values(&reg_no,'&name',&mark1,&mark2,&mark3);
Enter value for reg_no: 111
Enter value for name: surya
Enter value for mark1: 100
Enter value for mark2: 99
Enter value for mark3: 98
old 1: insert into student_info values(&reg_no,'&name',&mark1,&mark2,&mark3)
new 1: insert into student_info values(111,'surya',100,99,98)
1 row created.
SQL> /
Enter value for reg_no: 222
Enter value for name: karthi
Enter value for mark1: 97
Enter value for mark2: 96
Enter value for mark3: 95
old 1: insert into student_info values(&reg_no,'&name',&mark1,&mark2,&mark3)
new 1: insert into student_info values(222,'karthi',97,96,95)
1 row created.
SQL> /
Enter value for reg_no: 333
Enter value for name: manju
Enter value for mark1: 96
Enter value for mark2: 96
Enter value for mark3: 96
old 1: insert into student_info values(&reg_no,'&name',&mark1,&mark2,&mark3)
new 1: insert into student_info values(333,'manju',96,96,96)
1 row created.
SQL> /
Enter value for reg_no: 444
Enter value for name: saravanan
Enter value for mark1: 99
Enter value for mark2: 98
Enter value for mark3: 97
old 1: insert into student_info values(&reg_no,'&name',&mark1,&mark2,&mark3)
new 1: insert into student_info values(444,'saravanan',99,98,97)
1 row created.
SQL> /
Enter value for reg_no: 555
Enter value for name: mano
Enter value for mark1: 89
Enter value for mark2: 99
Enter value for mark3: 79
old 1: insert into student_info values(&reg_no,'&name',&mark1,&mark2,&mark3)
new 1: insert into student_info values(555,'mano',89,99,79)
1 row created.
SQL> /
Enter value for reg_no: 666
Enter value for name: prasath
Enter value for mark1: 99
Enter value for mark2: 88
Enter value for mark3: 77
old 1: insert into student_info values(&reg_no,'&name',&mark1,&mark2,&mark3)
new 1: insert into student_info values(666,'prasath',99,88,77)
1 row created.
SQL> /
Enter value for reg_no: 777
Enter value for name: dhanakumar
Enter value for mark1: 55
Enter value for mark2: 66
Enter value for mark3: 77
old 1: insert into student_info values(&reg_no,'&name',&mark1,&mark2,&mark3)
new 1: insert into student_info values(777,'dhanakumar',55,66,77)
1 row created.
SQL> /
Enter value for reg_no: 888
Enter value for name: praveen
Enter value for mark1: 78
Enter value for mark2: 88
Enter value for mark3: 98
old 1: insert into student_info values(&reg_no,'&name',&mark1,&mark2,&mark3)
new 1: insert into student_info values(888,'praveen',78,88,98)
1 row created.
SQL> /
Enter value for reg_no: 999
Enter value for name: selva
Enter value for mark1: 66
Enter value for mark2: 77
Enter value for mark3: 88
old 1: insert into student_info values(&reg_no,'&name',&mark1,&mark2,&mark3)
new 1: insert into student_info values(999,'ramu',66,77,88)
1 row created.
SQL> /
Enter value for reg_no: 100
Enter value for name: deepika
Enter value for mark1: 99
Enter value for mark2: 99
Enter value for mark3: 99
old 1: insert into student_info values(&reg_no,'&name',&mark1,&mark2,&mark3)
new 1: insert into student_info values(100,'deepika',99,99,99)
1 row created.
SQL> select * from student_info;
REG_NO NAME MARK1 MARK2 MARK3
--------- ---------------------------------------- --------- --------- ---------------------------
111 surya 100 99 98
222 karthi 97 96 95
333 manju 96 96 96
444 Savaranan 99 98 97
555 mano 89 99 79
666 prasath 99 88 77
777 dhanakumar 55 66 77
888 praveen 78 88 98
999 selva 66 77 88
100 deepika 99 99 S99
10 rows selected.
SQL> alter table student_info add(total number(6));
Table altered.
SQL> update student_info set total=mark1+mark2+mark3 where mark1>=50 and mark2>=50 and
mark3>=50;
10 rows updated.
SQL> select * from student_info;
REG_NO NAME MARK1 MARK2 MARK3 TOTAL
--------- ---------------------------------------- ------- --------- --------- ---------------------------
111 surya 100 99 98 297
222 karthi 97 96 95 288
333 manju 96 96 96 288
444 saravanan 99 98 97 294
555 mano 89 99 79 267
666 prasath 99 88 77 264
777 dhanakumar 55 66 77 198
888 praveen 78 88 98 264
999 selva 66 77 88 231
100 deepika 99 99 99 297
10 rows selected.
SQL> alter table student_info add(average number(7));
Table altered.
SQL> update student_info set average=total/3 where mark1>=50 and mark2>50 and mark3>=50;
10 rows updated.
SQL> select * from student_info;
REG_NO NAME MARK1 MARK2 MARK3 TOTAL AVERAGE
--------- ---------------------------------------- --------- --------- --------- --------- ---------
111 surya 100 99 98 297 99
222 karthi 97 96 95 288 96
333 manju 96 96 96 288 96
444 saravanan 99 98 97 294 98
555 mano 89 99 79 267 89
666 prasath 99 88 77 264 88
777 dhanakumar 55 66 77 198 66
888 praveen 78 88 98 264 88
999 ramu 66 77 88 231 77
100 deepika 99 99 99 297 99
10 rows selected.
SQL> select max(total) from student_info;
MAX(TOTAL)
----------
297
SQL> select min(total) from student_info;
MIN(TOTAL)
----------
198
SQL> select name,mark1 from student_info;
NAME MARK1
---------------------------------------- --------- ---------
surya 100
karthi 97
manju 96
Savaranan 99
mano 89
prasath 99
dhanakumar 55
praveen 78
selva 66
deepika 99
10 rows selected.
SQL> delete from student_info where name='ramu';
1 row deleted.
SQL> commit;
Commit complete.
SQL> delete from student_info where name='karthi';
1 row deleted.
SQL> rollback;
Rollback complete.
SQL> savepoint a;
Savepoint created.
Result:
EX.NO.2 DATABASE QUERYING – SIMPLE QUERIES, NESTED QUERIES,
SUB QUERIES AND JOINS
AIM:

PROCEDURE :
 JOINS: Joins are used to combine the data spread across table.
 Types of Joins:
 Natural Join: To join all the records in the tables.
 Inner Join: To combine the inner fields of data in table.
 Outer Join:
 Right Outer Join: To display same data in right side.
 Left Outer Join: To display same data in left side.
 Full Outer Join: To combine left and right outer join.
 NESTED (SUB) QUERIES: A sub query is a query inside another query.
 Set Comparison:
 Some Clause: to display some of the fields in a sub query.
 All Clauses: to display all fields in a nested query.
 Set Membership
 In clause: To display fields of data in the clause.
 Not in clause: To display fields of data in out clause.
OUTPUT:
SQL> create table surya (reg_no number,s_name varchar2(50),dept varchar2(50));
Table created.
SQL> desc surya;
Name Null? Type
------------------------------- -------- ----
REG_NO NUMBER
S_NAME VARCHAR2(50)
DEPT VARCHAR2(50)
SQL> insert into surya values(&reg_no,'&s_name','&dept');
Enter value for reg_no: 111
Enter value for s_name: prasath
Enter value for dept: cse
old 1: insert into surya values(&reg_no,'&s_name','&dept')
new 1: insert into surya values(111,'prasath','cse')
1 row created.
SQL> /
Enter value for reg_no: 333
Enter value for s_name: manju
Enter value for dept: IT
old 1: insert into surya values(&reg_no,'&s_name','&dept')
new 1: insert into surya values(333,'manju','IT')
1 row created.
SQL> /
Enter value for reg_no: 444
Enter value for s_name: deepika
Enter value for dept: cse
old 1: insert into surya values(&reg_no,'&s_name','&dept')
new 1: insert into surya values(444,'deepika','cse')
1 row created.
SQL> select * from surya;
REG_NO S_NAME DEPT
--------- --------------------------------------------------
111 prasath cse
333 manju IT
444 deepika cse
SQL> create table karthi(reg_no number(6),name varchar2(50),dept varchar2(30));
Table created.
SQL> desc karthi;
Name Null? Type
-------------------------- ------------- ----
REG_NO NUMBER(6)
NAME VARCHAR2(50)
DEPT VARCHAR2(30)
SQL> insert into karthi values(&reg_no,'&name','&dept');
Enter value for reg_no: 111
Enter value for name: mano
Enter value for dept: eee
old 1: insert into karthi values(&reg_no,'&name','&dept')
new 1: insert into karthi values(111,'mano','eee')
1 row created.
SQL> /
Enter value for sreg_no: 222
Enter value for name: saravanan
Enter value for dept: cse
old 1: insert into karthi values(&reg_no,'&name','&dept')
new 1: insert into karthi values(222,'saravanan','cse')
1 row created.
SQL> /
Enter value for reg_no: 333
Enter value for name: praveen
Enter value for dept: ece
old 1: insert into karthi values(&reg_no,'&name','&dept')
new 1: insert into karthi values(333,'praveen','ece')
1 row created.
SQL> /
Enter value for reg_no: 444
Enter value for name: selva
Enter value for dept: cse
old 1: insert into karthi values(&reg_no,'&name','&dept')
new 1: insert into karthi values(444,'selva','cse')
1 row created.
SQL> select * from karthi;
R EG_NO NAME DEPT
--------- -------------------------------------------------- -------------
111 mano eee
222 saravanan cse
333 praveen ece
444 selva cse
SQL> insert into surya values(222,'selva','cse');
1 row created.
SQL> select * from surya inner join karthi on surya.s_name=karthi.name;
REG_NO S_NAME DEPT REG_NO NAME DEPT
--------- ---------------------------------------------------------------------------
222 selva cse 444 selva cse
SQL> select * from surya right outer join karthi on surya.s_name=karthi.name;
REG_NO S_NAME DEPT REG_NO NAME DEPT
-------------------------------------------------- ----------------------------------------
222 selva cse 444 selva cse
333 praveen ece
222 saravanan cse
111 mano eee
SQL> select * from surya left outer join karthi on surya.s_name=karthi.name;
REG_NO S_NAME DEPT REG_NO NAME DEPT
-------------------------------------------------- -------------------------------------
222 selva cse 444 selva cse
333 manju IT
111 prasath cse
444 deepika cse
SQL> select * from surya full outer join karthi on surya.s_name=karthi.name;
REG_NO S_NAME DEPT REG_NO NAME DEPT
-------------------------------------------------- ----------------------------------------
222 selva cse 444 selva cse
333 manju IT 333 praveen ece
111 prasath cse 222 saravanan cse
444 deepika cse 111 mano eee
SQL> alter table karthi add(mark number(6));
Table alterd.
SQL> update karthi set mark=70 where name='mano';
1 row updated.
SQL> update karthi set mark=80 where name='selva';
1 row updated.
SQL> update karthi set mark=100 where name='saravanan';
1 row updated.
SQL> update karthi set mark=90 where name='praveen';
1 row updated.
SQL> select name,mark from karthi where mark>some(select mark from karthi where reg_no>=333);
NAME MARK
-------------------------------------------------- ---------
saravanan 100
praveen 90
SQL> select name,mark from karthi where mark>all(select mark from karthi where reg_no>=222);
no rows selected
SQL> select name,mark from karthi where mark>all(select mark from karthi where reg_no>=333);
NAME MARK
-------------------------------------------------- ---------
saravanan 100
SQL> select name,mark from karthi where mark>some(select mark from karthi where name='selva');
NAME MARK
-------------------------------------------------- ---------
saravanan 100
praveen 90
SQL> select name,mark from karthi where mark>some(select mark from karthi where
name='praveen');
NAME MARK
-------------------------------------------------- ---------
saravanan 100
SQL> select name,mark from karthi where mark>all(select mark from karthi where name='mano');
NAME MARK
-------------------------------------------------- ---------
saravanan 100
praveen 90
selva 80
SQL> select s_name from surya where s_name in (select name from karthi);
S_NAME
--------------------------------------------------
selva
SQL> select s_name from surya where s_name not in(select name from karthi);
S_NAME
--------------------------------------------------
prasath
manju
deepika

RESULT:
EX.NO:3 VIEWS, SEQUENCES, SYNONYMS
AIM :

PROCEDURE:
VIEW:
 A view is an object that gives the user a logical view of data from the underlying table.
Views may be created for simplifying queries and it provides data security,it can be
queried through base table.
 View commands are:
I. Creation of view
II. Selection data from a view.
III. Destroying a view.
 Create view:
It is used to create a view.
Syntax: create view view_name as select column_name,column_name from tablename;
 Select view:
To view the logical view of the data.
 Drop view:
It is used to delete the view.
Syntax: drop view view_name;
SEQUENCES
 Oracle provides the capability to generate sequences of unique numbers, and they are called
sequences.
 Sequences are used to generate unique, sequential integer values that are used as primary key
values in database tables.
 Sequence commands are
I.Create Sequence
II.Alter Sequence
III.Drop Sequence
 Create Sequence
It is used to create a Sequence.
Syntax: CREATE SEQUENCE sequence_name
START WITH initial_value
INCREMENT BY increment_value
MINVALUE minimum value
MAXVALUE maximum value
CYCLE|NOCYCLE ;
 Alter Sequence
A sequence once created can be altered.
Syntax: ALTER SEQUENCE <SequenceName> [INCREMENT BY <IntegerValue>
MINVALUE <IntegerValue> ]
 Drop Sequence
It is used to delete the Sequence.
Syntax: DROP SEQUENCE sequencename;
SYNONYMS
 A synonym is an alias, that is, a form of shorthand used to simplify the task of referencing a
database object.
 Synonyms commands are
I.Create Synonym
II. Drop Synonym
 Create Synonym
It is used to create a Synonym.
Syntax: Create [or replace] [public] synonym [schema .] synonym_name for [schema .]
object_name [@ dblink];
 Drop Synonym
It is used to delete the Synonym.
Syntax: DROP SYNONYM synonymname;
OUTPUT:
VIEW:
SQL> create table book (title varchar2(5),authorname varchar2(10),price number(5));
Table created.
SQL> insert into book values('dbms','silbers',300);
1 row created.
SQL> insert into book values('os','xyz',250);
1 row created.
SQL> insert into book values('ca','sas',230);
1 row created.
SQL> select * from book;
TITLE AUTHORNAME PRICE
----- ---------- ---------
dbms silbers 300
os xyz 250
ca sas 230
SQL> create view sunan as select title,authorname from book;
View created.
SQL> select * from sunan;
TITLE AUTHORNAME
----- ----------
dbms silbers
os xyz
ca sas
SQL> select title from sunan where authorname='silbers';
TITLE
-----
dbms
SQL> drop view sunan;
View dropped.
SEQUENCES
SQL> create table class(name varchar(10),id number(10));
Table created.
INSERT VALUES INTO TABLE:
SQL> insert into class values('&name',&id);
Enter value for name: anu
Enter value for id: 1
old 1: insert into class values('&name',&id)
new 1: insert into class values('anu',1)
1 row created.
SQL> /
Enter value for name: brindha
Enter value for id: 02
old 1: insert into class values('&name',&id)
new 1: insert into class values('brindha',02)
1 row created.
SQL> /
Enter value for name: chinthiya
Enter value for id: 03
old 1: insert into class values('&name',&id)
new 1: insert into class values('chinthiya',03)
1 row created.
SQL> select * from class;
NAME ID
---------- ----------
anu 1
brindha 2
chinthiya 3
CREATE SEQUENCE:
SQL> create sequence s_1
2 start with 4
3 increment by 1
4 maxvalue 100
5 cycle;
Sequence created.
SQL> insert into class values('divya',s_1.nextval);
1 row created.
SQL> select * from class;
NAME ID
---------- ----------
anu 1
brindha 2
chinthiya 3
divya 4
ALTER SEQUENCE:
SQL> alter sequence s_1
2 increment by 2;
Sequence altered.
SQL> insert into class values('fairoz',s_1.nextval);
1 row created.
SQL> select * from class;
NAME ID
---------- ----------
anu 1
brindha 2
chinthiya 3
divya 4
ezhil 5
fairoz 7
DROP SEQUENCE:
SQL> drop sequence s_1;
Sequence dropped.
SQL> select * from class;
NAME ID
---------- ----------
anu 1
brindha 2
chinthiya 3
divya 4
ezhil 5
fairoz 7
hema 9
7 rows selected.
CREATE SYNONYM:
SQL> create synonym c1 for class;
Synonym created.
SQL> insert into c1 values('kalai',20);
1 row created.
SQL> select * from class;
NAME ID
---------- ----------
anu 1
brindha 2
chinthiya 3
divya 4
ezhil 5
fairoz 7
hema 9
kalai 20
8 rows selected.
SQL> select * from c1;
NAME ID
---------- ----------
anu 1
brindha 2
chinthiya 3
divya 4
ezhil 5
fairoz 7
hema 9
kalai 20
8 rows selected.
SQL> insert into class values('Manu',21);
1 row created.
SQL> select * from c1;
NAME ID
---------- ----------
anu 1
brindha 2
chinthiya 3
divya 4
ezhil 5
fairoz 7
hema 9
kalai 20
Manu 21
9 rows selected.
DROP SYNONYM:
SQL> drop synonym c1;
Synonym dropped.
SQL> select * from c1;
select * from c1
ERROR at line 1:
ORA-00942: table or view does not exist
RESULT:
EX.NO:4 DATABASE PROGRAMMING: IMPLICIT AND EXPLICIT
CURSORS
AIM:

PROCEDURE:
IMPLICIT CURSORS:
Implicit cursor attributes can be used to access information about status of last insert, update,
delete or single - row select statement. This can be done by preceding the implicit cursor attribute with
cursor name.
EXPLICIT CURSORS
Explicit cursor is defined in the declarative part of a pl/sql block. This is done by naming the
cursor and mapping it to a query. The commands used to control the cursor are DECLARE, OPEN,
FETCH and CLOSE.
SYNTAX:
cursor cursor_name is select * from table name;
To open the cursor:
open cursor_name;
To close the cursor:
close cursor_name;
Output:
IMPLICIT CURSORS:
SQL> create table student(id number, name varchar2(10), dept varchar2(10), percent number,m1
number,m2 number, m3 number, tot number, g varchar2(1));
Table created.
SQL> select * from student;
ID NAME DEP PERCENT M1 M2 M3 TOT G

1 Anu it 0 90 89 80 0

2 Beena cse 0 98 91 95 0

3 Bindhu it 0 87 67 86 0

4 Varun it 0 67 46 50 0

5 Rahul cse 0 81 82 83 0
SQL> declare
2 cursor c is select * from student;
3 ctot number;
4 cgra varchar2(1);
5 cper number;
6 begin
7 for I in c
8 loop
9 ctot= i.m1+i.m2+i.m3;
10 cper :=ctot/3;
11 update student set tot = ctot where id =i.id;
12 update student set percent = cper where id =i.id;
13 if(cper between 91 and 100)then
14 cgra:= ‘S’
15 elsif(cper between 81 and 90)then
16 cgra:= ‘A’
17 elsif(cper between 71 and 80)then
18 cgra:= ‘B’
19 elsif(cper between 61 and 70)then
20 cgra:= ‘C’
21 elsif(cper between 56 and 60)then
22 cgra:= ‘D’
23 elsif(cper between 50 and 55)then
24 cgra:= ‘E’
25 else
26 cgra:= ‘F’
27 end if;
28 update student set g = cgra where id =i.id;
29 end loop;
30 end;
31 /
PL/ SQL procedure successfully completed.
SQL> select * from student;
ID NAME DEP PERCENT M1 M2 M3 TOT G

1 Anu it 86.3333333 90 89 80 259 A

2 Beena cse 94.6666667 98 91 95 284 S

3 Bindhu it 80 87 67 86 240 B

4 Varun it 54.3333333 67 46 50 163 E

5 Rahul cse 82 81 82 83 246 A

EXPLICIT CURSORS
SQL> select * from employee;
EMPNO NAME HRA DA PF NETSAL BASICPAY
101 AAA 0 0 0 0 15000
102 BBB 0 0 0 0 18000

103 CCC 0 0 0 0 20000

104 DDD 0 0 0 0 10000

105 EEE 0 0 0 0 25000

SQL> declare
2 cursor c is select * from employee;
3 i employee% rowtype;
4 hrasal number;
5 dasal number;
6 pfsal number;
7 netsalary number;
8 begin
9 open c;
10 loop;
11 fetch c into i;
12 if c% notfound ten exit;
13 endif;
14 hrasal:=i.basicpay*0.1;
15 dasal:=i.basicpay*0.08;
16 pfsal:=i.basicpay*0.12;
17 netsalaray:= i.basicpay + hrasal + dasal + pfsal;
18 update employee set hra = hrasal, da= dasal, pf= pfsal, netsal= netsalaray where
empno=i.empno;
19 end loop;
20 close c;
21 end;
22 /
PL/ SQL procedure successfully completed.
SQL> select * from employee;

EMPNO NAME HRA DA PF NETSAL BASICPAY

101 AAA 1500 1200 1800 15900 15000

102 BBB 1800 1440 2160 19080 18000

103 CCC 2000 1600 2400 21200 20000

104 DDD 1000 800 1200 10600 10000

105 EEE 2500 2000 3000 26500 25000

RESULT:
EX.NO.5: PROCEDURES AND FUNCTIONS
AIM:

PROCEDURE
PROCEDURE:

 A procedure is a subprogram that performs a specific action.


 To create a procedure:
Create or replace procedure procedure_name(arguments)as
Local declarations
Begin
Executable statements;
Exception
Exception handler
End;
 To execute a procedure:
o Ed procedure name;//opening the editor
o @procedre name;//creating the procedure
o Exec procedure name(parameters);//executing the procedures

FUNCTIONS
 A function is a sub program that computes a value.
 Syntax:
o To create a function:
Create or replace function function_name(arguments)as
Return data type is
Local declarations
Begin
Executable statements
Exception
Exception handler
End;
 To execute a function:
o Ed function name;//opening the editor
o @function name;//creating the function
o Exec function name(parameters);//executing the function

OUTPUT:

1. INSERT:

SQL> create table stack(pcode varchar2(15),pname varchar2(15),pqty number(5),pprice


number(5));

Table created
SQL> desc stack;

Name Null? Type

------------------------------- -------- ----

PCODE VARCHAR2(15)

PNAME VARCHAR2(15)

PQTY NUMBER(5)

PPRICE NUMBER(5)

PROCEDURE CREATION:

SQL> ed pro;

create or replace procedure create90(v1 varchar,v2 varchar,v3 number,v4 number)as

pcode varchar(15);

pname varchar(15);

pqty number(5);

pprice number(5);

begin

pcode:=v1;

pname:=v2;

pqty:=v3;

pprice:=v4;

insert into stack values(pcode,pname,pqty,pprice);

end;

SQL> @ pro;

13 /

Procedure created.

SQL> exec create90('p','book',20,700);

PL/SQL procedure successfully completed.

SQL> exec create90('c','pen',5,10);

PL/SQL procedure successfully completed.


SQL> exec create90('r','scale',8,3);

PL/SQL procedure successfully completed.

SQL> select * from stack;

PCODE PNAME PQTY PPRICE

--------------- --------------- --------- ---------

p book 20 700

c pen 5 10

r scale 8 3

SQL> ed prodel;

2. DELETION:

SQL> @ prodel;

8 /

Procedure created.

SQL> exec delete90('r');

PL/SQL procedure successfully completed.

3. UPDATE

SQL> create table student(roll_no number,name varchar2(20));

Table created.

SQL> desc student;

Name Null? Type

------------------------------- -------- ----

ROLL_NO NUMBER

NAME VARCHAR2(20)

SQL> ed student_proc;

create or replace procedure student_proc(v1 number,v2 varchar,v3 number,v4 varchar ) as

sroll_no number;

sname varchar2(20);
smark number;
sdept varchar;

begin

sroll_no:=v1;

sname:=v2;

smark:=v3;

sdept:=v4;

insert into student values(sroll_no,sname,smark,sdept);

end;

SQL> @ student_proc;

Procedure created.

SQL> exec student_proc(1,'surya');

PL/SQL procedure successfully completed.

SQL> select * from student;


ROLL_NO NAME
--------- --------------------
1 surya
SQL> exec student_proc(2,'guhan');
PL/SQL procedure successfully completed.

SQL> exec student_proc(3,'vikram');

PL/SQL procedure successfully completed.

SQL> select * from student;

ROLL_NO NAME
--------- --------------------
1 surya

2 guhan

3 vikram

FUNCTION

SQL> create table stack(pcode varchar(5),pname varchar2(15),qtyhand number,qtymin number);

Table created.

SQL> desc stack;


Name Null? Type
------------------------------- -------- ----
PCODE VARCHAR2(5)
PNAME VARCHAR2(15)

QTYHAND NUMBER

QTYMIN NUMBER

SQL> insert into stack values('p','pen',20,25);

1 row created.

SQL> insert into stack values('s','pencil',45,80);

1 row created.

SQL> insert into stack values('c','spen',34,45);

1 row created.

SQL> select * from stack;

PCODE PNAME QTYHAND QTYMIN


----- --------------- --------- ---------
p pen 20 25
s pencil 45 80
c spen 34 4

SQL> ed reorder;

FUNCTION:

create or replace function reorder_func(code varchar) return number is

reorderqty number;

minqty number;

handqty number;

begin

select qtyhand,qtymin into handqty,minqty from stack where

pcode=code;

if handqty<minqty then

reorderqty:=minqty-handqty;

return reorderqty;
else

reorderqty:=0;

return reorderqty;

end if;

end;

SQL> @ reorder;

16 /

Function created.

EXECUTING THE FUNCTION:

SQL> set serveroutput on

SQL> declare

2 a varchar(5);

3 b number;

4 begin

5 a:=&a;

6 b:=reorder_func(a);

7 dbms_output.put_line('quantity to be ordered is'||b);

8 end;

9 /

OUTPUT:

Enter value for a: 'p'

old 5: a:=&a;

new 5: a:='p';

quantity to be ordered is5

PL/SQL procedure successfully completed.

RESULT:
EX.NO:6 TRIGGERS
AIM:

PROCEDURE:
 Create a stock table with required fields.
 Create procedure for inserting values into the table.
 Insert the values into the table.
 Create procedure for updating the table.
 Create a trigger point to catch the illegal entry.

Update the table using update procedure.


SYNTAX
Create or replace trigger {schema]trigger name
{BEFORE, AFTER}
{DELETE, INSERT, UPDATE [OF column.....]}
ON [schema] table name
[REFERENCING {OLD AS old, NEW AS new}]
{FOR EACH ROW[WHEN condition]}
DECLARE
Variable declaration;
Constant declaration;
BEGIN
If inserting then
<PL/SQL block>
end if;
If updating then
<PL/SQL block>
end if;
if deleting then
<PL/SQL block> end if; EXCEPTION
Exception<PL/SQL
block> End;
Output:

SQL> create or replace triggers inve before update on invent


2 for each row
3 declare
4 begin
5 if: new.no_of_indiv<=10 then
6 Insert into orderit values(:new.itname,:new.no_of_indiv);
7 else
8 delete from orderit where itname=:new.itname;
9 end if;
10 end;
11 /
Trigger created SQL>select* from orderit;
ITNAME NO_OF_INDIV
hard disk 3
cd rom 5
ipod 2
SQL> select * from employ;
No rows selected
SQL> select * from emp_log;
No rows selected
SQL> create or replace trigger LOG_EMP
2 after insert or update or delete on employ
3 begin
4 if inserting then
5 insert into EMP_LOG values(user,’INSERT’,sysdate);
6 end if;
7 if updating then
8 insert into EMP_LOG values(user,’UPDATE’,sysdate);
9 end if;
10 if deleting then
11 insert into EMO_LOG values(user,’DELETE’,sysdate);
12 end if;
13 end;
14/
Trigger created
SQL>insert into employ values(„sachin‟,101);
1 row created
SQL>select *from emp_log;
USEDBY OPERATION SYSDATE
SCOTT INSERT 25-MAR-13
SQL>update employ set id=103 where id=101;
1 row updated.
SQL>select * from emp_log;
USEDBY OPERATION SYSDATE
SCOTT INSERT 25-MAR-13
SCOTT UPDATE 25-MAR-13
SQL> delete from employ where id=103;
1 row deleted
SQL>select *from emp_log;
USEDBY OPERATION SYSDATE

SCOTT INSERT 25-MAR-13

SCOTT UPDATE 25-MAR-13

SCOTT DELETE 25-MAR-13

RESULT:
EX.NO:7 EXCEPTION HANDLING
AIM:

PROCEDURE:
An error occurs during the program execution is called Exception in PL/SQL.
PL/SQL facilitates programmers to catch such conditions using exception block in the program
and an appropriate action is taken against the error condition.
There are two type of exceptions:
 System-defined Exceptions
 User-defined Exceptions
SYNTAX:
DECLARE
<declaration section>
BEGIN
<executable commands>
EXECPTION
<exception handling>
End:
OUTPUT:
SQL>select * from bank;
ACCNO DNAME BAL
101 trichy 37000

102 Deini 450

103 Mumbai 6000

104 chennai 2000

SQL>set serveroutput on;


SQL>declare
2 b number
3 n number
4 balanlow exception
5 balanok exception
6 begin
7 n:=&n;
8 select bal into b from bank where accno=n;
9 if (b<500)then
10 raise balanlow;
11 else
12 raise balanok;
13 end if;
14 exception
15 when balanlow then
16 dbms_output.put_line(‘YOUR balace is low’||b);
17 when balanok then
18 Dbms_output.put_line(YOUR balance is’||b);
19 end;
/
Enter value for n:102
Old 7: n:=&n; New 7:
n:=102;
YOUR balance is low 450
PL/SQL procedure successfully completed
SQL>
Enter value for n:103
Old 7: n:=&n; New 7:
n:=103;
YOUR balance is low 6000
PL/SQL procedure successfully completed

RESULT:
EX.NO:8 Database Design using ER modeling, normalization and Implementation for any
application
AIM:

DESCRIPTION:
In hospital, there are many departments like Orthopedic, Pathology, Emergency, Dental,
Gynecology, Anesthetics, I.C.U., Blood Bank, Operation Theater, Laboratory, M.R.I., Neurology,
Cardiology, Cancer Department, Corpse, etc. There is an OPD where patients come and get a card
(that is, entry card of the patient) for check up from the concerned doctor. After making entry in the
card, they go to the concerned doctor’s room and the doctor checks up their ailments. According
to the ailments, the doctor either prescribes medicine or admits the patient in the concerned
department. The patient may choose either private or general room according to his/her need. But
before getting admission in the hospital, the patient has to fulfill certain formalities of the hospital
like room charges, etc. After the treatment is completed, the doctor discharges the patient. Before
discharging from the hospital, the patient again has to complete certain formalities of the hospital
like balance charges, test charges, operation charges (if any), blood charges, doctors’ charges, etc.
Next we talk about the doctors of the hospital. There are two types of the doctors in the hospital,
namely, regular doctors and call on doctors. Regular doctors are those doctors who come to the
hospital daily. Calls on doctors are those doctors who are called by the hospital if the concerned
doctor is not available.
TABLE DESCRIPTION:
Following are the tables along with constraints used in Hospital Management database.
1. DEPARTMENT:
This table consists of details about the various departments in the hospital. The
information stored in this table includes department name, department location, and facilities
available in that department.
Constraint: Department name will be unique for each department.
2. ALL_DOCTORS:
This table stores information about all the doctors working for the hospital and
the departments they are associated with. Each doctor is given an identity number starting with
DR or DC prefixes only.
Constraint: Identity number is unique for each doctor and the corresponding
department should exist in DEPARTMENT table.
3. DOC_REG:
This table stores details of regular doctors working in the hospital. Doctors are
referred to by their doctor number. This table also stores personal details of doctors like name,
qualification, address, phone number, salary, date of joining, etc.
Constraint: Doctor’s number entered should contain DR only as a prefix and must exist in
ALL_DOCTORS table.
4. DOC_ON_CALL:
This table stores details of doctors called by hospital when additional doctors are
required. Doctors are referred to by their doctor number. Other personal details like name,
qualification, fees per call, payment due, address, phone number, etc., are also stored.
Constraint: Doctor’s number entered should contain DC only as a prefix and must exist in
ALL_DOCTORS table.
5. PAT_ENTRY:
The record in this table is created when any patient arrives in the hospital for a check
up. When patient arrives, a patient number is generated which acts as a primary key. Other
details like name, age, sex, address, city, phone number, entry date, name of the doctor referred
to, diagnosis, and department name are also stored. After storing the necessary details patient is
sent to the doctor for check up.
Constraint: Patient number should begin with prefix PT. Sex should be M or F only.
Doctor’s name and department referred must exist.
6. PAT_CHKUP:
This table stores the details about the patients who get treatment from the doctor
referred to. Details like patient number from patient entry table, doctor number, date of check
up, diagnosis, and treatment are stored. One more field status is used to indicate whether patient
is admitted, referred for operation or is a regular patient to the hospital. If patient is admitted,
further details are stored in PAT_ADMIT
table. If patient is referred for operation, the further details are stored in PAT_OPR table
and if patient is a regular patient to the hospital, the further details are stored in
PAT_REG table.
Constraint: Patient number should exist in PAT_ENTRY table and it should be
unique.
7. PAT_ADMIT: When patient is admitted, his/her related details are stored in this table.
Information stored includes patient number, advance payment, mode of payment, room
number, department, date of admission, initial condition, diagnosis, treatment, number of
the doctor under whom treatment is done, attendant name, etc.
Constraint: Patient number should exist in PAT_ENTRY table. Department, doctor
number, room number must be valid.
8. PAT_DIS: An entry is made in this table whenever a patient gets discharged from the
hospital. Each entry includes details like patient number, treatment given, treatment
advice, payment made, mode of payment, date of discharge, etc.
Constraint: Patient number should exist in PAT_ENTRY
table.
9. PAT_REG: Details of regular patients are stored in this table. Information stored
includes date of visit, diagnosis, treatment, medicine recommended, status of treatment,
etc.
Constraint: Patient number should exist in patient entry table. There can be multiple
entries of one patient as patient might be visiting hospital repeatedly for check up and
there will be entry for patient’s each visit.
10. PAT_OPR: If patient is operated in the hospital, his/her details are stored in this table.
Information stored includes patient number, date of admission, date of operation, number
of the doctor who conducted the operation, number of the operation theater in which
operation was carried out, type of operation, patient’s condition before and after
operation, treatment advice, etc.
Constraint: Patient number should exist in PAT_ENTRY table. Department, doctor
number should exist or should be valid.
11. ROOM_DETAILS: It contains details of all rooms in the hospital. The details stored in
this table include room number, room type (general or private), status (whether occupied
or not), if occupied, then patient number, patient name, charges per day, etc.
Constraint: Room number should be unique. Room type can only be G or P and status
can only be Y or N
E‐R Diagram

Relational Database Schema for Case Study


The relational database schema for Hospital Management database is as follows:
1. DEPARTMENT (D_NAME, D_LOCATION, FACILITIES)
2. ALL_DOCTORS (DOC_NO, DEPARTMENT)
3. DOC_REG(DOC_NO, D_NAME, QUALIFICATION, SALARY, EN_TIME,
EX_TIME, ADDRESS, PH_NO, DOJ)
4. DOC_ON_CALL (DOC_NO, D_NAME, QUALIFICATION, FS_PR_CL, PYMT_DU,
ADDRESS, PH_NO)
5. PAT_ENTRY (PAT_NO, PAT_NAME, CHKUP_DT, PT_AGE, SEX, RFRG_CSTNT,
DIAGNOSIS, RFD, ADDRESS, CITY, PH_NO, DEPARTMENT)
6. PAT_CHKUP (PAT_NO, DOC_NO, DIAGNOSIS, STATUS, TREATMENT)
7. PAT_ADMIT (PAT_NO, ADV_PYMT, MODE_PYMT, ROOM_NO, DEPTNAME,
ADMTD_ON, COND_ON, INVSTGTN_DN, TRMT_SDT, ATTDNT_NM)
8. PAT_DIS (PAT_NO, TR_ADVS, TR_GVN, MEDICINES, PYMT_GV, DIS_ON)
9. PAT_REG (PAT_NO, DATE_VIS, CONDITION, TREATMENT, MEDICINES, DOC_NO,
PAYMT)
10. PAT_OPR (PAT_NO, DATE_OPR, IN_COND, AFOP_COND, TY_OPERATION,
MEDICINES, DOC_NO, OPTH_NO, OTHER_SUG)
11. ROOM_DETAILS (ROOM_NO, TYPE, STATUS, RM_DL_CRG, OTHER_CRG)

RESULT:
EX.NO:9 DATABASE CONNECTIVITY WITH FRONT END TOOLS
AIM:

Procedure:

 Creating the Database


To create the table in Oracle
 Connection Process (Microsoft ODBC for Oracle)
 Open the Control Panel and Select the Administrative tools and select and Open
Data Sources.
 Click Add Button
 Select Microsoft ODBC for Oracle
 Click Finish Button.
 Give the Data Source Name ,User Name and Server Name and then Click OK
Button.
 Insert the values in the table
 Start Programs  to open Microsoft Visual Basic 6.0
 Open new standard Exe Project. Now form is opened.
 Place Label box, Text boxes and Command button.
 To add the Microsoft ADO control 6.0(OLEDB).
 Right Click in the Tool box and Select Components
 Add Microsoft ADO control 6.0(OLEDB)
 Click OK button.
 In ADODC control properties ,click Connection String and Properties pages will be
opened
 Select use Data Source Name and select the data source from the Drop down list
 Give the Authentication Name, Record Source Name
 Then click OK Button
 Then to click the text box in Form and give the Data Field & Date Source Name in
Properties window.
 Run the Program.
FRONT END TOOLS
CODING:
Private Sub Command1_Click()
Adodc1.Recordset.MoveFirst
End Sub
Private Sub Command2_Click()
Adodc1.Recordset.MovePrevious
End Sub
Private Sub Command3_Click()
Adodc1.Recordset.MoveNext
End Sub
Private Sub Command4_Click()
Adodc1.Recordset.MoveLast
End Sub
Private Sub Command5_Click()
Adodc1.Recordset.AddNew
End Sub
Private Sub Command6_Click()
Adodc1.Recordset.Delete
End Sub
Private Sub Command7_Click()
End
End Sub
FORMS

SQL> create table biodata(name varchar2(10),dept varchar2(3),perct number,phone


number,mailid varchar2(15),addstreet varchar2(10),addcity varchar2(10));
Table created.

In Form Builder - > Data Block Wizard,Connect with Oracle with Data source
Form Design:
Form Builder - >Designing Forms using Form

SQL> select * from biodata;


NAME DEP PERCT PHONE MAILID ADDSTREET ADDCITY
---------- --- --------- --------- --------------- ---------- ----------
Murugan IT 90 1.111E+09 [email protected] Palani Palani
Iyyappa CSE 90 222222222 [email protected] Sabarimala Kerala
Insertion:
Form Builder -> Run , Record - >Insert, Query->Execute
SQL> select * from biodata;
NAME DEP PERCT PHONE MAILID ADDSTREET ADDCITY
---------- --- --------- --------- --------------- ---------- ----------
Murugan IT 90 1.111E+09 [email protected] Palani Palani
Iyyappa CSE 90 222222222 [email protected] Sabarimala Kerala
Vinayaga IT 93 3.333E+09 [email protected] ganeshnaga Pilayarpat
Updation:
Form Builder -> Run , Select the field to update(change), Query->Execute

SQL> select * from biodata;


NAME DEP PERCT PHONE MAILID ADDSTREET ADDCITY
---------- --- --------- --------- --------------- ---------- ----------
Murugan IT 90 1.111E+09 [email protected] Palani Palani
Iyyappa CSE 90 222222222 [email protected] Sabarimala Kerala
Vinayaga IT 94 3.333E+09 [email protected] ganeshnaga Pilayarpat
Deletion:
Form Builder -> Run , Record->Remove, Query->Execute

SQL> select * from biodata;


NAME DEP PERCT PHONE MAILID ADDSTREET ADDCITY
---------- --- --------- --------- --------------- ---------- ---------
Murugan IT 90 1.111E+09 [email protected] Palani Palani
Iyyappa CSE 90 222222222 [email protected] Sabarimala Kerala

Result:
EX.NO:10 CASE STUDY USING REAL LIFE DATABASE APPLICATIONS
PASSPORT AUTOMATION SYSTEM

AIM

PROBLEM ANALYSIS AND PROJECT PLAN

To simplify the process of applying passport, software has been created by designing through
rational rose tool, using visual basic as a front end and Microsoft access as a back end. Initially the
applicant login the passport automation system and submits his details. These details are stored in the
database and verification process done by the passport administrator, regional administrator and police the
passport is issued to the applicant.
PROBLEM STATEMENT
1. Passport Automation System is used in the effective dispatch of passport to all of the applicants.
This system adopts a comprehensive approach to minimize the manual work and schedule
resources, time in a cogent manner.
2. The core of the system is to get the online registration form (with details such as name, address
etc.,) filled by the applicant whose testament is verified for its genuineness by the Passport
Automation System with respect to the already existing information in the database.
3. This forms the first and foremost step in the processing of passport application. After the first round
of verification done by the system, the information is in turn forwarded to the regional
administrator's (Ministry of External Affairs) office.
4. The application is then processed manually based on the report given by the system, and any
forfeiting identified can make the applicant liable to penalty as per the law.
5. The system forwards the necessary details to the police for its separate verification whose report is
then presented to the administrator. After all the necessary criteria have been met, the original
information is added to the database and the passport is sent to the applicant.
SOFTWARE REQUIREMENTS SPECIFICATION

SNO CONTENTS

1.0 Introduction
1.1 Purpose
1.2 Scope
1.3 Definition, Acronyms and Abbreviations
1.4 Reference
1.5 Technology to be used
1.6 Tools to be used
1.7 Overview
2.0 Overall description
2.1 Productive description
2.2 Software interface
2.3 Hardware interface
2.4 System function
2.5 User Characteristic
2.6 Constraints
2.7 Assumption and Dependences
1.0 INTRODUCTION
Passport Automation System is an interface between the Applicant and the Authority responsible
for the Issue of Passport. It aims at improving the efficiency in the Issue of Passport and reduces the
complexities involved in it to the maximum possible extent.

1.1 PURPOSE
If the entire process of 'Issue of Passport' is done in a manual manner then it would take several
months for the passport to reach the applicant. Considering the fact that the number of applicants for
passport is increasing every year, an Automated System becomes essential to meet the demand. So this
system uses several programming and database techniques to elucidate the work involved in this process.
As this is a matter of National Security, the system has been carefully verified and validated in order to
satisfy it.
1.2 SCOPE
The System provides an online interface to the user where they can fill in their personal details. The
authority concerned with the issue of passport can use this system to reduce his workload and process the
application in a speedy manner.Provide a communication platform between the applicant and the
administrator Transfer of data between the Passport Issuing Authority and the Local Police for verification
of applicant's information.
1.3 DEFINITIONS, ACRONYMS AND THE ABBREVIATIONS
1. Administrator - Refers to the super user who is the Central Authority who has been vested with the
privilege to manage the entire system. It can be any higher official in the Regional Passport Office
of Ministry of External Affairs.
2. Applicant - One who wishes to obtain the Passport.
3. PAS - Refers to this Passport Automation System.
1.4 REFERENCES • IEEE Software Requirement Specification format.
1.5 TECHNOLOGIES TO BE USED • Microsoft Visual Basic 6.0
1.6 TOOLS TO BE USED • Rational Rose tool (for developing UML Patterns)
1.7 OVERVIEW
SRS includes two sections overall description and specific requirements - Overall description will
describe major role of the system components and inter-connections. Specific requirements will describe
roles & functions of the actors.
2.0 OVERALL DESCRIPTION
2.1 PRODUCT PERSPECTIVE
The PAS acts as an interface between the 'applicant' and the 'administrator'. This system tries to make
the interface as simple as possible and at the same time not risking the security of data stored in. This
minimizes the time duration in which the user receives the passport.
2.2 SOFTWARE INTERFACE
1.Front End Client - The applicant and Administrator online interface is built using Microsoft Visual Basic
6.0.
2.Back End – MS Access database
2.3 HARDWARE INTERFACE
The server is directly connected to the client systems. The client systems have access to the
database in the server.
2.4 SYSTEM FUNCTIONS
1. Secure Registration of information by the Applicants.
2. Message box for Passport Application Status Display by the Administrator.
3. Administrator can generate reports from the information and is the only authorized personnel to add the
eligible application information to the database.
2.5 USER CHARACTERISTICS
1. Applicant - They are the people who desires to obtain the passport and submit the information to the
database.
2. Administrator - He has the certain privileges to add the passport status and to approve the issue of
passport. He may contain a group of persons under him to verify the documents and give suggestion
whether or not to approve the dispatch of passport.
3. Police - He is the person who upon receiving intimation from the PAS, perform a personal
verification of the applicant and see if he has any criminal case against him before or at present. He
has been vetoed with the power to decline an application by suggesting it to the Administrator if he
finds any discrepancy with the applicant. He communicates via this PAS.
2.6 CONSTRAINTS
1. The applicants require a computer to submit their information.
2. Although the security is given high importance, there is always a chance of intrusion in the web
world which requires constant monitoring.
3. The user has to be careful while submitting the information. Much care is required.
2.7 ASSUMPTIONS AND DEPENDENCIES
1. The Applicants and Administrator must have basic knowledge of computers and English Language.
2. The applicants may be required to scan the documents and send.
UML DIAGRAMS

Sno UML DIAGRAMS


1 Use Case diagram
2 Class diagram
3 Interaction diagram
4 Sequence diagram
5 Collaboration diagram
6 State Chart diagram
7 Activity diagram
8 Component diagram
9 Deployment diagram
10 Package diagram
USE CASE DIAGRAM:

DOCUMENTATION OF USECASE DIAGRAM


a. The actors in use case diagram are Applicant, regional administrator, database, passport
Administrator, Police.
b. The use cases are Login, givedetails, logout, collectdetails, verification, issue.
c. The actors use the use case are denoted by the arrow
d. The login use case checks the username and password for applicant, regional administrator,
passport administrator and police.
e. The submit details use case is used by the applicant for submitting his details
f. The check status use case is used by the applicant for checking the status of the application
process.
g. The get details, verify and store verification use case is used by passport administrator,
regional administrator, and police.
h. The details use case is used for getting the details form the database for verification
i. The verify use case is used for verifying the details by comparing the data in the database
j. The store verification use case is to update the data in the database
k. And finally the issue passport use case is used by the passport administrator for issuing
passport who’s application verified successfully by all the actor .
CLASS DIAGRAM

A class is drawn as rectangle box with three compartments or components separated by horizontal
lines. The top compartment holds the class name and middle compartment holds the attribute and bottom
compartment holds list of operations.

DOCUMENTATION OF CLASS DIAGRAM


a. APPLICANT-The applicant has attribute such as name and password and operations are
login, givedetails and logout. The applicant login and fill the details that are required for
applying the passport .After applying the person can view the status of the passport
verification process
b. THE DATABASE-The database has attributed such as name and operation is store. The
purpose is to store the data.
c. REGIONAL ADMINISTRATOR- The regional administrator has attribute such as name
and operation are get details, verify details and send. The regional administrator get the
details form database and verify with their database
d. PASSPORT ADMINISTRATOR-The passport administrator has attributed such as name
and operation are get details, verify details and issue. The passport administrator get the
details form database and verify with their database , update the verification and issue the
passport
e. THE POLICE-The police has attribute such as name and operation are get details, verify
details and send. The police get the details form database and verify with their database ,
update the verification in the database
SEQUENCE DIAGRAM
A sequence diagram shows an interaction arranged in time sequence, It shows object participating
in interaction by their lifeline by the message they exchange arranged in time sequence. Vertical dimension
represent time and horizontal dimension represent object.

DOCUMENTATION OF SEQUENCE DIAGRAM.


a. The applicant login the database and give his details and database store the details.
b. The passport administrator get the details from the database and do verification and the
forward to regional administrator.
c. The regional administrator get details form passport administrator and perform verification
and send report to passport administrator.
d. The police get the details form passport administrator and perform verification and send
report to passport administrator
COLLABORATION DIAGRAM

A collaboration diagram is similar to sequence diagram but the message in number format. In a
collaboration diagram sequence diagram is indicated by the numbering the message. A collaboration
diagram, also called a communication diagram or interaction diagram, A sophisticated modeling tool can
easily convert a collaboration diagram into a sequence diagram and the vice versa. A collaboration diagram
resembles a flowchart that portrays the roles, functionality and behavior of individual objects as well as the
overall operation of the system in real time

1: 1.requirement for registration


2: 2.registration form
3: 3.fill in details
APPLICANT
4: 4.submit
5: 5.give applicant id

SYSTEM

DATABASE 6: 6.store full details


STATE CHART DIAGRAM

The state chart diagram contains the states in the rectangle boxes and starts in indicated by the dot
and finish is indicated by dot encircled. The purpose of state chart diagram is to understand the algorithm in
the performing method

DOCUMENTATION OF STATE CHART DIAGRAM


a. The states of the passport automation system are denoted in the state chart diagram
b. Login state represent authentication for login the passport automation system.
c. In this state, it checks whether the applicant has provided all the details that is required.
d. Police, regional administrator and passport administrator get necessary details and
verification of the applicant are denoted from the Get detail state and verification state
ACTIVITY DIAGRAM
An activity diagram is a variation or special case of a state machine in which the states or activity
representing the performance of operation and transitions are triggered by the completion of operation. The
purpose is to provide view of close and what is going on inside a use case or among several classes. An
activity is shown as rounded box containing the name of operation

DOCUMENTATION OF ACTIVITY DIAGRAM


a. The activities in the passport automation system are login, submit details, get details, issue
passport and penalty and verification.
b. In the login activity applicant give username and password and then login into the passport
automation system after then fill the details that are required for application.
c. After the verification procedure completed successfully the passport is issued to the
applicant.
COMPONENT DIAGRAM
The component diagram is represented by figure dependency and it is a graph of design of figure
dependency. The component diagram's main purpose is to show the structural relationships between the
components of systems. It is represented by boxed figure. Dependencies are represented by communication
association
DOCUMENTATION OF COMPONENT DIAGRAM
a. The components in the passport automation system are passport automation system,
applicant, passport administrator, regional administrator, and police.
b. Applicant ,passport administrator, regional administrator and police are dependent on
passport automation system are shown by the dotted arrow
DEPLOYMENT DIAGRAM
It is a graph of nodes connected by communication association. It is represented by a three
dimensional box. A deployment diagram in the unified modeling language serves to model the physical
deployment of artifacts on deployment targets. Deployment diagrams show "the allocation of artifacts to
nodes according to the Deployments defined between them. It is represented by 3-dimentional box.
Dependencies are represented by communication association. The basic element of a deployment diagram
is a node of two types
DEVICE NODE
A physical computing resource with processing and memory service to execute software, such as a
typical computer or a mobile phone.
EXECUTION ENVIRONMENT NODE

This is a software computing resource that runs within an outer node and which itself provides a
service to host an execute other executable software element.

DOCUMENTATION OF DEPLOYMENT DIAGRAM

The device node is passport automation system and execution environment node are applicant
passport administrator, regional administrator, and police.
PACKAGE DIAGRAM

A package diagram is represented as a folder shown as a large rectangle with a top attached to its
upper left corner. A package may contain both sub ordinate package and ordinary model elements. All uml
models and diagrams are organized into package. A package diagram in unified modeling language that
depicts the dependencies between the packages that make up a model. A Package Diagram (PD) shows a
grouping of elements in the OO model, and is a Cradle extension to UML. PDs can be used to show groups
of classes in Class Diagrams (CDs), groups of components or processes in Component Diagrams (CPDs),
or groups of processors in Deployment Diagrams (DPDs).
There are three types of layer. They are
o User interface layer
o Domain layer
o Technical services layer

DOCUMENTATION OF PACKAGE DIAGRAM


The three layer in the passport automation system are user interface layer, domain layer, technical
service layer
a. The user interface layer- represents the user interface components such as web, applicant,
passport administrator, police, and regional administrator.
b. The domain layer- has major actions such as give and get details, verification and issues.
c. Technical service layer- authenticated user only can access the technical services.
FORM1:

FORM2:
FORM3:

FORM4:
FORM5:

FORM6:
FORM7:

SOURCE CODE:

FORM1
Private Sub Command1_Click()
Dim app As Applicant
Set app = New Applicant
app.Login
End Sub
Private Sub Command2_Click()
Dim pass As PassportAdministrator
Set pass = New PassportAdministrator
pass.Login
End Sub
Private Sub Command3_Click()
Dim reg As RegionalAdminstrator
Set reg = New RegionalAdminstrator
reg.Login
End Sub
Private Sub Command4_Click()
Dim pol As Police
Set pol = New Police
pol.Login
End Sub
Private Sub Command5_Click()
If Form1.Text1.Text = "" And Form1.Text2.Text = "" Then
MsgBox "LOGIN SUCCESSFUL"
Form6.Show
Else
MsgBox "INVALID USERNAME AND PASSWORD"
Unload Me
End If
End Sub
Private Sub Command6_Click()
End
End Sub

FORM2:
Private Sub Command1_Click()
Dim subdetails As Applicant
Set subdetails = New Applicant
subdetails.SubmitDetails
End Sub
Private Sub Command3_Click()
Data1.Recordset.Edit
End Sub
Private Sub Command4_Click()
Data1.Recordset.update
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
End Sub

FORM3:
Private Sub a_Click()
Data2.Recordset.AddNew
End Sub
Private Sub Command1_Click()
Dim search As PassportAdministrator
Set search = New PassportAdministrator
search.update
End Sub
Private Sub Command2_Click()
If Data1.Recordset.BOF Then
MsgBox "NO DATA FOUND"
Else
Data1.Recordset.MovePrevious
End If
End Sub
Private Sub Command3_Click()
If Data1.Recordset.EOF Then
MsgBox "NO DATA FOUND"
Else
Data1.Recordset.MoveNext
End If
End Sub
Private Sub Command4_Click()
Form1.Show
Unload Me
End Sub
Private Sub Command5_Click()
Data1.Recordset.MoveFirst
End Sub
Private Sub Command6_Click()
Data1.Recordset.MoveLast
End Sub
Private Sub Command7_Click()
Data1.Recordset.Edit
Data1.Recordset.Fields(9) = "successful"
Data1.Recordset.update
End Sub
Private Sub Command8_Click()
Data1.Recordset.Edit
Data1.Recordset.Fields(9) = "unsuccessful"
Data1.Recordset.update
End Sub
Private Sub ve_Click()
Dim verify As PassportAdministrator
Set verify = New PassportAdministrator
verify.update
End Sub

FORM4:
Private Sub Command1_Click()
Dim search As RegionalAdminstrator
Set search = New RegionalAdminstrator
search.verify
End Sub
Private Sub Command2_Click()
Data1.Recordset.Edit
Data1.Recordset.Fields(10) = "successful"
Data1.Recordset.update
End Sub
Private Sub Command3_Click()
Data1.Recordset.Edit
Data1.Recordset.Fields(10) = "unsuccessful"
Data1.Recordset.update
End Sub
Private Sub Command4_Click()
Form1.Show
Unload Me
End Sub
Private Sub Command5_Click()
Dim update As RegionalAdminstrator
Set update = New RegionalAdminstrator
update.update
End Sub
Private Sub Command6_Click()
Data1.Recordset.MoveLast
End Sub
Private Sub Command7_Click()
Data1.Recordset.MoveFirst
End Sub
Private Sub Command8_Click()
If Data1.Recordset.BOF Then
MsgBox "NO DATA FOUND"
Else
Data1.Recordset.MovePrevious
End If
End Sub
Private Sub Command9_Click()
If Data1.Recordset.EOF Then
MsgBox "NO DATA FOUND"
Else
Data1.Recordset.MoveNext
End If
End Sub

FORM5:
Private Sub Command1_Click()
Dim search As Police
Set search = New Police
search.verify
End Sub
Private Sub Command2_Click()
Data2.Recordset.Edit
Data2.Recordset.Fields(11) = "successful"
Data2.Recordset.update
End Sub
Private Sub Command3_Click()
Data2.Recordset.Edit
Data2.Recordset.Fields(11) = "unsuccessful"
Data2.Recordset.update
End Sub
Private Sub Command4_Click()
Form1.Show
Unload Me
End Sub
Private Sub Command6_Click()
Data2.Recordset.MoveLast
End Sub
Private Sub Command7_Click()
Data2.Recordset.MoveFirst
End Sub
Private Sub Command8_Click()
If Data2.Recordset.BOF Then
MsgBox "NO DATA FOUND"
Else
Data2.Recordset.MovePrevious
End If
End Sub
Private Sub Command9_Click()
If Data2.Recordset.EOF Then
MsgBox "NO DATA FOUND"
Else
Data2.Recordset.MoveNext
End If
End Sub

FORM6:
Private Sub Command1_Click()
Dim checkstate As Applicant
Set checkstate = New Applicant
checkstate.CheckStatus
End Sub
Private Sub Command2_Click()
Form1.Show
Unload Me
End Sub

RESULT:

You might also like