0% found this document useful (0 votes)
22 views64 pages

It Dbms Manual

The document outlines the academic details and laboratory work for the Database Management Systems course at Mohamed Sathak A.J College of Engineering for the academic year 2021-2022. It includes a bonafide certificate, an index of experiments, and detailed procedures for various database operations such as Data Definition Language (DDL) and Data Manipulation Language (DML) commands. The document serves as a record of practical examinations and experiments conducted by students in the Information Technology department.

Uploaded by

nausheennazar14
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)
22 views64 pages

It Dbms Manual

The document outlines the academic details and laboratory work for the Database Management Systems course at Mohamed Sathak A.J College of Engineering for the academic year 2021-2022. It includes a bonafide certificate, an index of experiments, and detailed procedures for various database operations such as Data Definition Language (DDL) and Data Manipulation Language (DML) commands. The document serves as a record of practical examinations and experiments conducted by students in the Information Technology department.

Uploaded by

nausheennazar14
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/ 64

MOHAMED SATHAK A.

J COLLEGE OF
ENGINEERING
(Approved by AICTE, New Delhi and Affiliated to Anna University)
34, Old Mahabalipuram Road, Egattur, Chennai – 603 103.

ISO 9001: 2008 Certified Institution

Sponsored By: MOHAMED SATHAK TRUST, Chennai – 600 034.

(ACADEMIC YEAR: 2021- 2022)

CS8481- DATABASE MANAGEMENT SYSTEMS LABORATORY

Name :

Register Number :

Department : INFORMATION TECHNOLOGY

Year / Semester :

(ANNA UNIVERSITY: CHENNAI - 600 025)


MOHAMED SATHAK A.J
COLLEGE OF ENGINEERING
(Approved by AICTE, New Delhi and Affiliated to Anna University) 34, Old
Mahabalipuram Road, Egattur, Chennai – 603 103.

ISO 9001: 2008 Certified Institution

Sponsored By: MOHAMED SATHAK TRUST, Chennai – 600 034.

BONAFIDE CERTIFICATE

This is to certify that this is the Bonafide Record of work done by


Mr. /Ms... ………………………………………………………………………..
Register Number ............................................................................................ of
II YEAR / IV Semester – INFORMATION TECHNOLOGY in the
CS8481- DATABASE MANAGEMENT SYSTEMS LABORATORY during
the Academic year 2021-2022

Staff In-Charge Head of the Department

Submitted for the Anna University Practical Examination held on

Internal Examiner External Examiner


INDEX

PAGE
EX. SIGN
DATE TITLE NO
NO

1a DATA DIFINITION COMMENT 1

DATA MANIPULATION AND


1.b TRANSACTION CONTROL 9
STATEMENTS

2 DATABASE QUERYING – SIMPLE 12


QUERIES, NESTED QUERIES, SUB
QUERIES AND JOINS

VIEWS, SEQUENCES, SYNONYMS


3 14

4 DATABASE PROGRAMMING: IMPLICIT 16


AND EXPLICI CURSORS

PROCEDURES AND FUNCTIONS


5 17

6 TRIGGERS 19

7 EXCEPTION HANDLING 21

DATABASE DESIGN USING ER MODELING,


8 22
NORMALIZATION AND IMPLEMENTATION
FOR ANYAPPLICATION
DATABASE CONNECTIVITY WITH FRONT END
9 23
TOOLSSYSTEM

10 CASE STUDY USING REAL LIFE DATABASE 24


APPLICATIONS PASSPORT AUTOMATION

11 CASE STUDY USING REAL LIFE DATABASE 58


APPLICATIONS ON RAILWAY
RESERVATION
Expt.No: 1.a DATA DEFINITION COMMANDS
Date:

AIM:
To study the usage of various Data Definition Language commands like creating table, Alter table,
Drop table and Truncating Table.
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 table name (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 table name
d. Drop table: It is used to delete the table
Syntax: drop table table name;
OUTPUT:
1. CREATE COMMAND
SQL> create table student(same 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:
Thus the usage of various Data Definition Language commands like creating table,alter,drop
and truncating the tables are studied and executed successfully
Expt.No: 1.b DATA MANIPULATION AND TRANSACTION CONTRO STATEMENTS
Date:

AIM:
To study the usage of various Data Manipulation Language commands like insert, delete,
update, deleting the records as well as fields of data and transaction control commands like
commit,rollback,savepoint.
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:
Thus the usage of various Data Manipulation Language commands like inserting, deleting,
updating, displaying records or fields of data and transaction control commands like
commit,rollback,savepoint in a table are studied and executed successfully.
Expt.No: 2
DATABASE QUERYING – SIMPLE QUERIES, NESTED
Date:
QUERIES, SUB QUERIES AND JOINS

AIM:
To study the usage of join queries and nested queries (sub queries).
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:
Thus the usage of joins and nested(sub) queries are studied and executed successfully.
Expt.No: 3
VIEWS, SEQUENCES, SYNONYMS
Date:
AIM :
To study the usage of view command.
PROCEDURE:
VIEW:
 A view is an object that gives the user a logical view of data from the underlyingtable.
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
adatabase 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:
Thus the Views, Synonyms, and Sequences command was executed successfully.
Expt.No: 4 DATABASE PROGRAMMING: IMPLICIT AND EXPLICI CURSORS
Date:

AIM:
To perform database programming for implicit and explicit cursors.
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:
Thus the database programming for implicit and explicit cursors are executed successfully.
Expt.No: 5
PROCEDURES AND FUNCTIONS
Date:
AIM:
To implement procedures and functions using PL / SQL.
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:
Thus the procedures and functions using PL / SQL are executed successfully.
Expt.No: 6 TRIGGERS
Date:

AIM:
To implement triggers using PL / SQL.
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 orderitvalues(: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_LOGvalues(user,’INSERT’,sysdate);
6 end if;
7 if updating then
8 insert into EMP_LOGvalues(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:
Thus the triggers using PL / SQL are executed successfully.
Expt.No: 7 EXCEPTION HANDLING
Date:

AIM: To implement exception handling using PL / SQL.


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:
Thus the exception handling using PL / SQL are executed successfully.
Expt.No: 8 DATABASE DESIGN USING ER MODELING, NORMALIZATION AND
Date:
IMPLEMENTATION FOR ANY APPLICATION

AIM:
XYZ hospital is a multi-specialty hospital that includes a number of departments, rooms,
Doctors, nurses, compounders, and other staff working in the hospital. Patients having different kinds
of ailments come to the hospital and get checkup done from the concerned doctors. If required they are
admitted in the hospital and discharged after treatment.

The aim of this case study is to design and develop a database for the hospital to maintain the records
of various departments, rooms, and doctors in the hospital. It also maintains records of the regular
patients, patients admitted in the hospital, the checkup of patients done by the doctors, the patients that
have been operated, and patients discharged from the hospital.
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, doctornumber,
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 storedincludes 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, numberof
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:
Thus the ER Database design using E-R model and Normalization was implemented
successfully.
Expt.No: 9 DATABASE CONNECTIVITY WITH FRONT END TOOLS
Date:

AIM:

To display student details and to perform database connectivity where Visual Basic act as
front end and Oracle act as back end.

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:
Thus the details of student application was developed and executed successfully.
Expt.No: 10 CASE STUDY USING REAL LIFE DATABASE APPLICATIONS
Date:
PASSPORTAUTOMATION SYSTEM

AIM

To develop the Passport Automation System using rational rose tools, visual basic and MS access.

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.
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
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.

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.
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.
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.
REFERENCES • IEEE Software Requirement Specification format.
TECHNOLOGIES TO BE USED • Microsoft Visual Basic 6.0
TOOLS TO BE USED • Rational Rose tool (for developing UML Patterns)
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.
OVERALL DESCRIPTION
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.
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
HARDWARE INTERFACE
The server is directly connected to the client systems. The client systems have access to the database
in the server.
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.
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.
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.
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.

SOURCE CODE:

FORM1
Private Sub
Command1_Click() Dim

51
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
En
d If
En
d
Su
b
Private Sub
Command6_Click() End
End Sub

FORM2:
Private Sub
Command1_Click() Dim
52
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.Add
New 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.MovePre
vious End If
End Sub
Private Sub
Command3_Click() If

53
Data1.Recordset.EOF
Then MsgBox "NO DATA
FOUND"
Else
Data1.Recordset.Move
Next End If
End Sub
Private Sub
Command4_Click()
Form1.Show
Unloa
d Me
End
Sub
Private Sub
Command5_Click()
Data1.Recordset.MoveFirs
t 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
54
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
Unloa
d 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.MoveFirs
t End Sub
Private Sub
Command8_Click() If
Data1.Recordset.BOF
Then MsgBox "NO DATA
FOUND" Else
Data1.Recordset.MovePre
vious End If
End Sub
Private Sub
Command9_Click() If
Data1.Recordset.EOF
Then MsgBox "NO DATA
FOUND"
Else
Data1.Recordset.Move

55
Next 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
Unloa
d Me
End
Sub
Private Sub
Command6_Click()
Data2.Recordset.MoveLast
End Sub
Private Sub
Command7_Click()
Data2.Recordset.MoveFirs
t End Sub
Private Sub
Command8_Click() If
Data2.Recordset.BOF
Then MsgBox "NO DATA
FOUND"
Else
Data2.Recordset.MovePre
vious End If
End Sub
Private Sub
Command9_Click () If

56
Data2.Recordset.EOF
Then MsgBox "NO DATA
FOUND"
Else
Data2.Recordset.Move
Next 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
Unloa
d Me
End
Sub

RESULT:
Thus the project to develop passport automation system was developed using Rational Rose
Software and to implement the software in Visual Basic is done successfully.
Expt.No: 11 CASE STUDY USING REAL LIFE DATABASE APPLICATIONS ON
Date:
RAILWAY RESERVATION.

Aim: The railway reservation system facilitates the passengers to enquire about the trains available on the basis of
source and destination, booking and cancellation of tickets, enquire about the status of the booked ticket, etc.
The aim of case study is to design and develop a database maintaining the records of different trains, train status,
and passengers. The record of train includes its number, name, source, destination, and days on which it is available,
whereas record of train status includes dates for which tickets can be booked, total number of seats available, and
number of seats already booked. The database has been developed and tested on the Oracle.
Description:
Passengers can book their tickets for the train in which seats are available. For this, passenger has to provide the
desired train number and the date for which ticket is to be booked. Before booking a ticket for a passenger, the
validity of train number and booking date is checked. Once the train number and booking date are validated, it is
checked whether the seat is available. If yes, the ticket is booked with confirm status and corresponding ticket ID is
generated which is stored along with other details of the passenger. After all the available tickets are booked, certain
numbers of tickets are booked with waiting status. If waiting lot is also finished, then tickets are not booked and a
message of non‐availability of seats is displayed.
The ticket once booked can be cancelled at any time. For this, the passenger has to provide the ticket ID (the unique
key). The ticket ID is searched and the corresponding record is deleted. With this, the first ticket with waiting status
also gets confirmed.
List of Assumption
Since the reservation system is very large in reality, it is not feasible to develop the case study to that extent and
prepare documentation at that level. Therefore, a small sample case study has been created to demonstrate the
working of the reservation system. To implement this sample case study, some assumptions have been made, which
are as follows:

1. The number of trains has been restricted to 5.

2. The booking is open only for next seven days from the current date.

3. Only two categories of tickets can be booked, namely, AC and General.

4. The total number of tickets that can be booked in each category (AC and General) is 10.
5. The total number of tickets that can be given the status of waiting is 2.
6. The in‐between stoppage stations and their bookings are not considered.
Description of Tables and Procedures
Tables and procedures that will be created are as follows:
1. TrainList: This table consists of details about all the available trains. The information stored in this table
includes train number, train name, source, destination, fair for AC ticket, fair for general ticket, and weekdays
on which train is available.

Constraint: The train number is unique.


2. Train_Status: This table consists of details about the dates on which ticket can be booked for a train and the
status of the availability of tickets. The information stored in this table includes train number, train date, total
number of AC seats, total number of general seats, number of AC seats booked, and number of general seats
booked.

Constraint: Train number should exist in TrainList table.


3. Passenger: This table consists of details about the booked tickets. The information stored in this table includes
ticket ID, train number, date for which ticket is booked, name, age, sex and address of the passenger, status
of reservation (either confirmed or waiting), and category for which ticket is booked.

Constraint: Ticket ID is unique and the train number should exist in TrainList table.

4. Booking: In this procedure, the train number, train date, and category is read from the passenger. On the basis
of the values provided by the passenger, corresponding record is retrieved from the Train_Status table. If the
desired category is AC, then total number of AC seats and number of booked AC seats are compared in order
to find whether ticket can be booked or not. Similarly, it can be checked for the general category. If ticket can
be booked, then passenger details are read and stored in the Passenger table.

5. Cancel: In this procedure, ticket ID is read from the passenger and corresponding record is searched in the
Passenger table. If the record exists, it is deleted from the table. After deleting the record (if it is confirmed),
first record with waiting status for the same train and same category are searched from the Passenger table
and its status is changed to confirm.
E‐R diagram
VIVA QUESTION AND ANSWER

1) Define Database.

A prearranged collection of figures known as data is called database.

2) What is DBMS?
Database Management Systems (DBMS) are applications designed especially which enable
userinteraction with other applications.

3) What are the various kinds of interactions catered by DBMS?


The various kind of interactions catered by DBMS are:
 Data definition
 Update
 Retrieval
 Administration
4) Segregate database technology’s development.
The development of database technology is divided into:
 Structure or data model
 Navigational model
 SQL/ relational model
5) Who proposed the relational model?
Edgar F. Codd proposed the relational model in 1970.

6) What are the features of Database language?


A database language may also incorporate features like:DBMS-specific Configuration and
management of storage engine Computations to modification of query results by computations,
like summing, counting, averaging, grouping, sorting and cross-referencing Constraint
enforcement Application Programming Interface

7) What do database languages do?


As special-purpose languages, they have:
 Data definition language
 Data manipulation language
 Query language

8) Define database model.


A data model determining fundamentally how data can be stored, manipulated and organised
andthe structure of the database logically is called database model.
9) What is SQL?
Structured Query Language (SQL) being ANSI standard language updates database
andcommands for accessing.
10) Enlist the various relationships of database.
The various relationships of database are:
 One-to-one: Single table having drawn relationship with another table having similar kind of
columns.
 One-to-many: Two tables having primary and foreign key relation.
 Many-to-many: Junction table having many tables related to many tables.
58
11) Define Normalization.
Organized data void of inconsistent dependency and redundancy within a database is
called normalization.

12) Enlist the advantages of normalizing database.


Advantages of normalizing database are:
 No duplicate entries
 Saves storage space
 Boasts the query performances.

13) Define Denormalization.


Boosting up database performance, adding of redundant data which in turn helps rid of
complex data is called denormalization.

14) Define DDL and DML.


Managing properties and attributes of database is called Data Definition Language(DDL).
Manipulating data in a database such as inserting, updating, deleting is defined as
Data Manipulation Language. (DML)
15) Enlist some commands of DDL.
They are:

CREATE:
Create is used in the CREATE TABLE statement. Syntax is:
CREATE TABLE [column name] ( [column definitions] ) [ table parameters]

ALTER:
It helps in modification of an existing object of database. Its syntax is:
ALTER objecttype objectname parameters.

DROP:
It destroys an existing database, index, table or view. Its syntax is:
DROP objecttype objectname.

16) Define Union All operator and Union.


Full recordings of two tables is Union All
operator. A distinct recording of two tables is
Union.
17) Define cursor.
A database object which helps in manipulating data row by row representing a result set is
called cursor.
18) Enlist the cursor types.
They are:
 Dynamic: it reflects changes while scrolling.
 Static: doesn’t reflect changes while scrolling and works on recording of snapshot.
 Keyset: data modification without reflection of new data is seen.

59
19) Enlist the types of cursor.
They types of cursor are:
 Implicit cursor: Declared automatically as soon as the execution of SQL takes place without the
awareness of the user.
20) Explicit cursor: Defined by PL/ SQL which handles query in more than one row.Define sub-query.
A query contained by a query is called Sub-query.
21) Why is group-clause used?
Group-clause uses aggregate values to be derived by collecting similar data.
22) Compare Non-clustered and clustered index
Both having B-tree structure, non-clustered index has data pointers enabling one table many
non- clustered indexes while clustered index is distinct for every table.
23) Define Aggregate functions.
 Functions which operate against a collection of values and returning single value is
calledaggregate functions.Define Scalar functions.
 Scalar function is depended on the argument given and returns sole value.

24) What restrictions can you apply when you are creating views?
Restrictions that are applied are:
 Only the current database can have views.
 You are not liable to change any computed value in any particular view.
 Integrity constants decide the functionality of INSERT and DELETE.
 Full-text index definitions cannot be applied.
 Temporary views cannot be created.
 Temporary tables cannot contain views.
 No association with DEFAULT definitions.
 Triggers such as INSTEAD OF is associated with views.

25) Define “correlated subqueries”.


A ‘correlated subquery’ is a sort of sub query but correlated subquery is reliant on another
query for a value that is returned. In case of execution, the sub query is executed first and
thenthe correlated query.
26) Define Data Warehousing.
Storage and access of data from the central location in order to take some strategic decision is
called Data Warehousing. Enterprise management is used for managing the information
whoseframework is known as Data Warehousing.

27) Define Join and enlist its types.


Joins help in explaining the relation between different tables. They also enable you to select data
with relation to data in another table.
The various types are:
 INNER JOINs: Blank rows are left in the middle while more than equal to two tables are
joined.
 OUTER JOINs: Divided into Left Outer Join and Right Outer Join. Blank rows are left at the
specified side by joining tables in other side.

Other joins are CROSS JOINs, NATURAL JOINs, EQUI JOIN and NON-EQUI JOIN.

60
28. How many Triggers are possible in MySQL?

There are six Triggers allowed to use in MySQL database.


1. Before Insert
2. After Insert
3. Before Update
4. After Update
5. Before Delete
6. After Delete

29. Why MySQL is used?


MySQL database server is reliable, fast and very easy to use. This software can be downloaded as f
reeware and can be downloaded from the internet.
30. Difference between CHAR and VARCHAR?
Following are the differences between CHAR and VARCHAR:
 CHAR and VARCHAR types differ in storage and retrieval
 CHAR column length is fixed to the length that is declared while creating table. The length
value ranges from 1 and 255
 When CHAR values are stored then they are right padded using spaces to specificlength.
Trailing spaces are removed when CHAR values are retrieved.

61

You might also like