It Dbms Manual
It Dbms Manual
J COLLEGE OF
ENGINEERING
(Approved by AICTE, New Delhi and Affiliated to Anna University)
34, Old Mahabalipuram Road, Egattur, Chennai – 603 103.
Name :
Register Number :
Year / Semester :
BONAFIDE CERTIFICATE
PAGE
EX. SIGN
DATE TITLE NO
NO
6 TRIGGERS 19
7 EXCEPTION HANDLING 21
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
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(®_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(®_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(®_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(®_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(®_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(®_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(®_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(®_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(®_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(®_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(®_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
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(®_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(®_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(®_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(®_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
REG_NO NUMBER(6)
NAME VARCHAR2(50)
DEPT VARCHAR2(30)
SQL> insert into karthi values(®_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(®_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(®_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(®_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(®_no,'&name','&dept')
new 1: insert into karthi values(444,'selva','cse')
1 row created.
SQL> select * from karthi;
R EG_NO NAME DEPT
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
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
3 Bindhu It 80 87 67 86 240 B
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
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;
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:
OUTPUT:
1. INSERT:
Table created
SQL> desc stack;
PCODE VARCHAR2(15)
PNAME VARCHAR2(15)
PQTY NUMBER(5)
PPRICE NUMBER(5)
PROCEDURE CREATION:
SQL> ed pro;
pcode varchar(15);
pname varchar(15);
pqty number(5);
pprice number(5);
begin
pcode:=v1;
pname:=v2;
pqty:=v3;
pprice:=v4;
end;
SQL> @ pro;
13 /
Procedure created.
P book 20 700
C Pen 5 10
R scale 8 3
SQL> ed prodel;
2. DELETION:
SQL> @ prodel;
8 /
Procedure created.
3. UPDATE
Table created.
ROLL_NO NUMBER
NAME VARCHAR2(20)
SQL> ed student_proc;
sroll_no number;
sname varchar2(20);
smark number;
sdept varchar;
begin
sroll_no:=v1;
sname:=v2;
smark:=v3;
sdept:=v4;
end;
SQL> @ student_proc;
Procedure created.
ROLL_NO NAME
1 surya
2 guhan
3 vikram
FUNCTION
Table created.
PCODE VARCHAR2(5)
PNAME VARCHAR2(15)
QTYHAND NUMBER
QTYMIN NUMBER
1 row created.
1 row created.
1 row created.
P Pen 20 25
S pencil 45 80
C spen 34 4
SQL> ed reorder;
FUNCTION:
reorderqty number;
minqty number;
handqty number;
begin
pcode=code;
if handqty<minqty then
reorderqty:=minqty-handqty;
return reorderqty;
else
reorderqty:=0;
return reorderqty;
end if;
end;
SQL> @ reorder;
16 /
Function created.
SQL> declare
2 a varchar(5);
3 b number;
4 begin
5 a:=&a;
6 b:=reorder_func(a);
8 end;
9/
OUTPUT:
old 5: a:=&a;
new 5: a:='p';
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.
RESULT:
Thus the triggers using PL / SQL are executed successfully.
Expt.No: 7 EXCEPTION HANDLING
Date:
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
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:
In Form Builder - > Data Block Wizard,Connect with Oracle with Data source
Form Design:
Form Builder - >Designing Forms using Form
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.
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
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:
2. The booking is open only for next seven days from the current date.
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: 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.
2) What is DBMS?
Database Management Systems (DBMS) are applications designed especially which enable
userinteraction with other applications.
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.
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.
Other joins are CROSS JOINs, NATURAL JOINs, EQUI JOIN and NON-EQUI JOIN.
60
28. How many Triggers are possible in MySQL?
61