Lab Manual3
-
Upload
sivamuthucse -
Category
Documents
-
view
234 -
download
0
Transcript of Lab Manual3
-
8/10/2019 Lab Manual3
1/118
1
SEC CSE/IV DBMS LAB MANUAL
SRINIVASAN ENGINEERING COLLEGECOMPUTER SCIENCE AND ENGINEERING
ANNA UNIVERSITY OF TECHNOLOGY, CHENNAI
REGULATION 2009
II CSE (2011-2015)
CS2254
DATABASE MANAGEMENT SYSTEM LABORATORY
LAB MANUAL
BY
C.SARANYA, Assistant Professor.
-
8/10/2019 Lab Manual3
2/118
-
8/10/2019 Lab Manual3
3/118
3
SEC CSE/IV DBMS LAB MANUAL
TABLE OF CONTENTS
CHAPTER NO TOPIC PAGE NO
I
Introduction to the language
Main Features
Advantages
Limitations
Applications
4
5
6
7
II Syllabus 10
III System Requirements 11
IV
Description about each experiment
AimLearning ObjectiveGeneral procedure to executeprograms
V Experiments
1 Data Definition, Table creation, Constraints 15
2 Insert, Select Commands, Updates, Delete Commands 21
3 Nested Queries & Join Queries 27
4 Views 38
5(a) Control structures 46
5(b) Procedures 54
5(c) Functions 58
6 Front End Tools 64
7 Forms 73
8 Triggers 76
9 Menu Design 86
10 Reports 91
11(a) Database design and implementation(Mini Project) 100
11(b) Database design and implementation(Library management) 105
-
8/10/2019 Lab Manual3
4/118
4
SEC CSE/IV DBMS LAB MANUAL
INTRODUCTION OF THE LANGUAGE
HISTORY OF ORACLE:
Larry Ellison and his friends, former co-workers Bob Miner and Ed Oates, started the
consultancy Software Development Laboratories (SDL) in 1977. SDL developed the original
version of the Oracle software.For more than three and a half decades, Oracle has been the leader
in database software. And as it has further developed technologies and acquired best-in-class
companies over the years, that leadership has expanded to the entire technology stack, from
servers and storage, to database and middleware, through applications and into the cloud.
It all began when Larry Ellison saw an opportunity other companies missed: a description
of a working prototype for a relational database. No company had committed to commercializing
the technology, but Ellison and co-founders Bob Miner and Ed Oates realized the tremendous
business potential of the relational database model. None of them realized at the time that the
company they formed would change the face of business computing.
Throughout its history Oracle has proved it can build for the future on the foundation of
its innovations and its knowledge of customer challenges and successes analyzed by the best
technical and business minds in the world.
DIFFERENT VERSIONS OF ORACLE:
The latest Oracle versions that are in use are Oracle 11g, Oracle 10g , Oracle 9i. Some
companies are still using Oracle 8i but Oracle does not support this version any more. Oracle 11g
is the latest version and companies are slowly upgrading their databases to 11g but it takes
another couple of years before all the companies move into 11g.Currently majority of companies
prefer to be on oracle 10g as 10g has lot of features. The g in 10g stands for 'Grid' . This means
the concept where multiple computers can be used together to make the database more powerful.
This is called the grid concept. Oracle 10g with RAC(real application clusters) is viewed by lot
of companies to be very powerful and following the Grid concept.
-
8/10/2019 Lab Manual3
5/118
-
8/10/2019 Lab Manual3
6/118
6
SEC CSE/IV DBMS LAB MANUAL
database administrator (DBA) is responsible to create users, assign privileges, add
records, delete redundant information, and modify existing data
and process queries. This centrally stored data is shared and accessed by
variousapplications. This eliminates data entry and data storage redundancy.
Standardization
o A major advantage of Oracle SQL is its standardization and consistency among
various different implementations. SQL was first standardized by ANSI
(American Standards Institute) in 1986, and further ratified in 1987 by the
International Organization for Standardization (ISO), which remains its
standardization body.
LIMITATIONS:
Inability to Implement Recursive Processing
o According to "SQL for Dummies," one of the major drawbacks of SQL is its
incapability to execute recursive processing. Recursive processing is a type of
computer function (or program) in which one of the steps of a program (or
procedure) reruns the entire program (or procedure). SQL lacks looping
constructs that are common in other high-level programming languages, such as
for and what loops. It cannot repeat actions and there is no way to define
repetitive looping constructs in SQL.
Incompatibility and Complexity
o One of the major disadvantages of Oracle SQL is inconsistency and data
incompatibility in the areas of time and date syntax, string concatenation and case
sensitivity. The language is complex, with a keyword approach similar in
structure to COBOL (common business-oriented language), with fewer syntax
and grammar rules.
-
8/10/2019 Lab Manual3
7/118
7
SEC CSE/IV DBMS LAB MANUAL
Limited Functionality
o SQL is a domain specific or special-purpose language, and its use is limited to a
specific program domain. SQL statements are operated on tables and sets of data,
such as personnel databases and accounting spreadsheets. SQL is a declarative
domain specific language that is limited to the tabular representation of data.
APPLICATIONS:
PRODUCT LINES
Oracle offers more than ten comprehensive product lines, including Oracle E-Business Suite,
Siebel, Primavera, PeopleSoft, and ATG. Each product line is designed to meet specific business
needs in areas such as sales, business intelligence, enterprise resource planning, commerce, and
more.
Agile
ATG
AutoVue
Documaker
Endeca
Hyperion
JD Edwards EnterpriseOne
JD Edwards World
Taleo
Knowledge Management
Oracle Crystal Ball
Oracle CRM On Demand
Oracle E-Business Suite
Oracle Fusion Applications
-
8/10/2019 Lab Manual3
8/118
8
SEC CSE/IV DBMS LAB MANUAL
BUSINESS APPLICATIONS
Oracle offers more than 200 applications that address specific category-based business
requirements such as customer relationship management, financial management,
governance, risk, and compliance, project management, and more.
Business Analytics
Business Process Services
Customer Experience
Commerce Solution
Customer Relationship Management
Customer Self-Service
Enterprise Performance Management
Financial Management
Governance, Risk, and Compliance
Human Capital Management
Master Data Management
Oracle Policy Automation
Oracle Social Relationship Management
Procurement
Project Portfolio Management
Supply Chain Management
Transportation Management
INDUSTRY APPLICATIONS
Oracle's industry solutions are best-in-class products that address complex business processes
relevant to a wide range of industries. Oracle's solutions speed time to market, reduce costs, anddeliver a competitive edge.Engineering and Construction
Professional Services
Public Sector
Retail
Travel and Transportation
-
8/10/2019 Lab Manual3
9/118
9
SEC CSE/IV DBMS LAB MANUAL
IMPLEMENTATION AND INTEGRATION TOOLS
Oracle has a complete and open set of tools to provide sustainable integration across Oracle
and Non-Oracle Applications, best-practices that streamline new implementation at low risk,
and user-friendly tools to ensure success and accelerate user adoption.
Oracle Application Integration
Oracle Business Accelerators
Oracle User Productivity Kit
USES:
Increase productivity through real time component data.
Design reusability
Security for the users.
Connects as Back End for more number of consumption.
Useful in Report generation
-
8/10/2019 Lab Manual3
10/118
10
SEC CSE/IV DBMS LAB MANUAL
CHAPTER 2
LIST OF EXPERIMENTS
1. Data Definition, Table Creation, Constraints,
2. Insert, Select Commands, Update and Delete Commands.
3. Nested Queries and Join Queries
4. Views
5. High level programming language extensions (Control structures, Procedures and
Functions).6. Front End tools
7. Forms
8. Triggers
9. Menu Design
10. Reports.
11. Database Design and implementation (Mini Project).
-
8/10/2019 Lab Manual3
11/118
11
SEC CSE/IV DBMS LAB MANUAL
SYSTEM REQUIREMENTS
HARDWARE REQUIREMENTS
Processors - 2.0 GHz or Higher
RAM - 256 MB or Higher
Hard Disk - 20 GB or Higher
Operating System - Windows 2000/XP/NT
SOFTWARE REQUIREMENTS
Oracle 9i
Database Connectivity
-
8/10/2019 Lab Manual3
12/118
12
SEC CSE/IV DBMS LAB MANUAL
ABOUT THE DATABASE MANAGEMENT AND SYSTEMS LABORATORY
Aim of the Database management systems laboratory:
The main objective of this laboratory upon successful completion of this Lab the student will beable to:
Create database objects
Modify database objects
Manipulate the data
Retrieve the data from the database server
Perform database operations in a procedural manner using pl/sql
Performing database operations (create, update, modify, retrieve,etc.,) using front-end tools like D2K.
Design and Develop applications like banking, reservation system,
OVERVIEW OF THE EXPERIMENTS
EXPERIMENT NO . 1 : (Data Definition, Table Creation, Constraints)
Data Definition, Table Creation, Constraints is used to describe the
concepts of table creation for a database.
Constraints are used to limit the type of data that can go into a table. It can
be specified when the table is created(WITH CREATE TABLE statement)
or after the table is created (with the ALTER TABLE statement).
EXPERIMENT NO . 2: (Insert, Select Commands, Update & Delete Commands.)
Insert into statement is used to insert a new row in a table.
The SELECT statement is used to select data from database.
8
-
8/10/2019 Lab Manual3
13/118
13
SEC CSE/IV DBMS LAB MANUAL
The Result is stored in the result table, called the result set.
EXPERIMENT NO . 3 (Nested Queries & Join Queries)
Join combines records from two or more tables in a database. It creates a
set that can be saved as a table or used as it is. A JOIN is a means forcombining fields from two tables by using values common to each.
Nested query is a query in a query. A subquery is usually added in the
WHERE Clause of the sql statement. Most of the time, a subquery is used
when you know how to search for a value using a SELECT statement, but
do not know the exact value.
EXPERIMENT NO. 4 (Views)
A view is a virtual relation that does not necessarily exist in the database
but can be produced upon request by a particular user at the time of request.
EXPERIMENT NO. 5: (High level programming language extensions (Control
structures, Procedures and Functions).)
A function is a named PL/SQL block which is similar to a procedure. The
major difference between a procedure and a function is, a function mustalways return a value. But a procedure may or may not return a value.
A stored procedure or in a simple a proc is a named PL/SQL block which
performs one or more specific task. A procedure may or may not return a
value.
EXPERIMENT NO . 6: (Front end tools)
Front end tools are used in Designing, Compiling, Running Forms in
Oracle Developer and Executing in SQL.
EXPERIMENT NO . 7: (Forms)
Forms are used to enter data into databases and to extract information from
database via predefined queries.
Eg:- www
-
8/10/2019 Lab Manual3
14/118
14
SEC CSE/IV DBMS LAB MANUAL
EXPERIMENT NO . 8: (Triggers)
A trigger is a pl/sql block structure which is fired when a DML statements
like insert, delete, update is executed on a database table. A trigger is
triggered automatically
when an associated DML statement is execute.
EXPERIMENT NO . 9: (Menu Design)
List of choices is provided by database developers for the benefit of users.
Menu Editor can create menus and menu items quickly and easily using form
builder.
EXPERIMENT NO. 10: (Reports)
Report generators are used to generate human readable summary
reports from a database.
Eg:- bar or pie graphs or charts.
EXPERIMENT NO. 11: (Database Design and implementation (Mini Project)
Implementation of library system and payroll processing using databaseconnectivity
LEARNING OBJECTIVES:
To be gather knowledge about database connectivity
Can know about SQL commands
-
8/10/2019 Lab Manual3
15/118
15
SEC CSE/IV DBMS LAB MANUAL
EX.NO:1
DATE: Data Definition, Table Creation, Constraints
DESCRIPTION:
Data definition language (DDL) statements let you to perform these tasks:
Create, alter, and drop schema objects
Grant and revoke privileges and roles
Analyze information on a table, index, or clusterEstablish auditing options
Add comments to the data dictionary
The CREATE, ALTER, and DROP commands require exclusive access to the specified object. For
example, an ALTER TABLE statement fails if another user has an open transaction on the specified
table.
The GRANT, REVOKE, ANALYZE, AUDI T, and COMMENT commands do not require exclusive access tothe specified object. For example, you can analyze a table while other users are updating the
table.
Oracle Database implicitly commits the current transaction before and after every DDL
statement.Many DDL statements may cause Oracle Database to recompile or reauthorize schema
objects. For information on how Oracle Database recompiles and reauthorizes schema objects
and the circumstances under which a DDL statement would cause this, see Oracle Database
Concepts.DDL statements are supported by PL/SQL with the use of the DBMS_SQLpackage.
-
8/10/2019 Lab Manual3
16/118
16
SEC CSE/IV DBMS LAB MANUAL
The DDL statements are:
ANALYZE ALTER
ASSOCIATE STATISTICS AUDIT COMMENT CREATE DISASSOCIATE STATISTICS DROP
FLASHBACK TRUNCATE UNDROP
OBJECTIVE:
To practice and implement data definition language commands and constraints.
SYNTAXES & KEYWORDS:
CREATE( ) Used to Create the table SELECT ( ) Used to select the values from the table
UPDATE ( ) Used to update the values from the table DELETE ( ) Used to delete the particular values, data from the table
REQUIREMENTS FOR EXECUTION :
S.No. Facilities
required
Quantity
1 System 1
2 OS windows Xp
3 S/W Name Oracle ip
-
8/10/2019 Lab Manual3
17/118
17
SEC CSE/IV DBMS LAB MANUAL
ALGORITHM:
1. Create a table.2. DML commands are Insert,Select,Update,Delete.3. The retrieval of information stored in the database.The insertion of
new information into the database4. The deletion of information from the database.The modification of
information stored in the database5. Execute the commands
DML COMMAND
Data Manipulation commands are the most frequently used SQL commands and they areas follow. DML commands are Insert,Select,Update,Delete.
QUERY
SQL> SELECT * FROM STU1;
8 rows selected.
SNAME RNO DEPTTMARKS
----------- ------- ------- ------------
MANO MC345 MCA 450
DIVYA MC321 MCA 445
HARISH IT356 BE 460
BALA CSE123 BE 434
Vinu EEE07 BE 400
Anu ECE01 BE 432
MADHU MC100 MCA 421
SANJU EEE132 BE 412
-
8/10/2019 Lab Manual3
18/118
18
SEC CSE/IV DBMS LAB MANUAL
INSERT
SQL> INSERT INTO STU1
VALUES('KRISH','MC123','MCA',440); 1 row created.
SQL> SELECT * FROM STU1;
SNAME RNO DEPT TMARKS
------------ ------ --------- -------------
MANO MC345 MCA 450
DIVYA MC321 MCA 445
HARISH IT356 BE 460
BALA CSE123 BE 434
Vinu EEE07 BE 400
Anu ECE01 BE 432
MADHU MC100 MCA 421
SANJU EEE132 BE 412
KRISH MC123 MCA 440
9 rows selected.
DELETE
SQL> DELETE FROM STU1 WHERE
RNO='ECE01'; 1 row deleted.
SQL> SELECT * FROM STU1;
-
8/10/2019 Lab Manual3
19/118
19
SEC CSE/IV DBMS LAB MANUAL
SNAME RNO DEPT TMARKS
----------- ------- -------- ------------
MANO MC345 MCA 450
DIVYA MC321 MCA 445
HARISH IT356 BE 460
BALA CSE123 BE 434
Vinu EEE07 BE 400
MADHU MC100 MCA 421
SANJU EEE132 BE 412
KRISH MC123 MCA 440
8 rows selected.
UPDATE
SQL> UPDATE STU1 SET TMARKS=TMARKS+20 WHERE RNO='EEE07'; 1 row
updated.
SQL> SELECT * FROM STU1;SNAME RNO DEPT TMARKS---------- ------- -------- ------------MANO MC345 MCA 450DIVYA MC321 MCA 445HARISH IT356 BE 460BALA CSE123 BE 434VINU EEE07 BE 420MADHU MC100 MCA 421
8 rowsselected.
-
8/10/2019 Lab Manual3
20/118
20
SEC CSE/IV DBMS LAB MANUAL
RESULT:
The program for Data Manipulation language command has been executed and the output
for queries are as displayed .
VIVA QUESTION AND ANSWER:
1. Define the terms DML
DML: A data manipulation language is a language that enables users to access or
manipulate data as organized by the appropriate data model.
2. Define weak and strong entity sets?
Weak entity set: entity set that do not have key attribute of their own are called weakentity sets.
Strong entity set: Entity set that has a primary key is termed a strong entity set.
POSSIBLE QUESTIONS:
1. Create an employee table with required fields and work DML commands
2. Create a student table with required fields and work DML commands
3. Create a student table with required fields
a.alter
b.truncate
4. Create a student table with required fields
a.alter
b.drop
-
8/10/2019 Lab Manual3
21/118
-
8/10/2019 Lab Manual3
22/118
22
SEC CSE/IV DBMS LAB MANUAL
OBJECTIVE :
To perform insert, update, delete operation using DML commands.
REQUIREMENTS FOR EXECUTION :
S.No. Facilities
required
Quantity
1 System 1
2 OS windows Xp
3 S/W Name Oracle ip
ALGORITHM:
1. Create a table.2. DML commands are Insert,Select,Update,Delete.3. The retrieval of information stored in the database.The insertion of
new information into the database
4. The deletion of information from the database.The modification ofinformation stored in the database5. Execute the commands
DML COMMAND
Data Manipulation commands are the most frequently used SQL commands and they are as
follow. DML commands are Insert,Select,Update,Delete.
QUERY:
SQL> SELECT * FROM STU1;
MANO MC345 MCA 450
DIVYA MC321 MCA 445
HARISH IT356 BE 460
-
8/10/2019 Lab Manual3
23/118
23
BALA CSE123 BE 434
Vinu EEE07 BE 400
anu ECE01 BE 432
MADHU MC100 MCA 421
SANJU EEE132 BE 412
8 rows selected.
INSERT
SQL> INSERT INTO STU1
VALUES('KRISH','MC123','MCA',440); 1 row created.
SQL> SELECT * FROM STU1;
SNAME RNO DEPT TMARKS
------------ ------ --------- -------------
MANO MC345 MCA 450
DIVYA MC321 MCA 445
HARISH IT356 BE 460
BALA CSE123 BE 434
Vinu EEE07 BE 400
anu ECE01 BE 432
MADHU MC100 MCA 421
SANJU EEE132 BE 412
KRISH MC123 MCA 440
9 rows selected.
-
8/10/2019 Lab Manual3
24/118
24
SEC CSE/IV DBMS LAB MANUAL
DELETE
SQL> DELETE FROM STU1 WHERE
RNO='ECE01'; 1 row deleted.
SQL> SELECT * FROM STU1;
SNAME RNO DEPT TMARKS
----------- ------- -------- ------------
MANO MC345 MCA 450
DIVYA MC321 MCA 445
HARISH IT356 BE 460
BALA CSE123 BE 434
Vinu EEE07 BE 400
MADHU MC100 MCA 421
SANJU EEE132 BE 412
KRISH MC123 MCA 440
8 rows selected.
UPDATE
SQL> UPDATE STU1 SET TMARKS=TMARKS+20 WHERE
RNO='EEE07'; 1 row updated.
SQL> SELECT * FROM STU1;
SNAME RNO DEPT TMARKS
---------- ------- -------- ------------
-
8/10/2019 Lab Manual3
25/118
25
MANO MC345 MCA 450
DIVYA MC321 MCA 445
HARISH IT356 BE 460
BALA CSE123 BE 434
Vinu EEE07 BE 420
MADHU MC100 MCA 421
SANJU EEE132 BE 412
KRISH MC123 MCA 440
8 rows selected.
VIVA QUESTION AND ANSWER
1. What is DBMS and whats the goal of it?
DBMS is a collection of interrelated data and a set of programs to access that data. The goal is to provide
the environment that is both convenient and efficient to use in retrieving and storing data base
information.
2. What are the advantages of DBMS?
Centralized Control Data Independence allows dynamic change and growth potential.
Data Duplication is eliminated with control Redundancy. Data Quality is enhanced.
EXTRA QUESTIONS
1. What is DDL?
2. Why TRUNCATE is used?
-
8/10/2019 Lab Manual3
26/118
26
SEC CSE/IV DBMS LAB MANUAL
POSSIBLE QUESTIONS
1. Create a student table with required fields and work DDL commands
2. Create a student table with required fields
a.alter b.truncate
3. Create a student table with required fieldsa.alter b.drop
-
8/10/2019 Lab Manual3
27/118
27
SEC CSE/IV DBMS LAB MANUAL
EX.NO:3
DATE:Nested Queries and Join Queries.
DESCRIPTION:
NESTED QUERY OR SUB QUERY
A Subquery or Inner query or Nested query is a query within another SQL query, and embedded
within the WHERE clause.
A subquery is used to return data that will be used in the main query as a condition to further
restrict the data to be retrieved.
Subqueries can be used with the SELECT, INSERT, UPDATE, and DELETE statements along
with the operators like =, , >=,
-
8/10/2019 Lab Manual3
28/118
28
SEC CSE/IV DBMS LAB MANUAL
SQL JOIN
The JOIN keyword is used in an SQL statement to query data from two or more tables, based ona relationship between certain columns in these tables.
Tables in a database are often related to each other with keys.
A primary key is a column (or a combination of columns) with a unique value for each row.
Each primary key value must be unique within the table. The purpose is to bind data together,
across tables, without repeating all of the data in every table.
Look at the "Persons" table:
P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
Note that the "P_Id" column is the primary key in the "Persons" table. This means that no two
rows can have the same P_Id. The P_Id distinguishes two persons even if they have the same
name.
Next, we have the "Orders" table:
O_Id OrderNo P_Id
1 77895 3
2 44678 3
3 22456 1
-
8/10/2019 Lab Manual3
29/118
29
SEC CSE/IV DBMS LAB MANUAL
4 24562 1
5
34764 15
Note that the "O_Id" column is the primary key in the "Orders" table and that the "P_Id"
column refers to the persons in the "Persons" table without using their names.
Notice that the relationship between the two tables above is the "P_Id" column.
OBJECTIVE:
To perform nested queries and joining queries using DML command Description:
REQUIREMENTS FOR EXECUTION:
ALGORITHM:
1. Create a table
2. JOIN OPERATION: Join is a query in which data is retrieved from two or more table
Different types of join
3. Inner join: Inner join returns the matching rows from the tables that are being joined
4. Outer join: When the tables are joined using inner join, rows which containing matching
values in the join predict are returned
5. Execute the commands
S.No. Facilities
required
Quantity
1 System 1
2 OS Oracle 9i
-
8/10/2019 Lab Manual3
30/118
30
SEC CSE/IV DBMS LAB MANUAL
QUERY:
SQL> insert into muthu values('&a','&b','&c','&d','pass');
Enter value for a: 101
Enter value for b: john
Enter value for c: 89
Enter value for d: 80
old 1: insert into muthu values('&a','&b','&c','&d','pass')
new 1: insert into muthu values('101','john','89','80','pass')
1 row created.
SQL> insert into muthu values('&a','&b','&c','&d','pass');
Enter value for a: 102
Enter value for b: Raja
Enter value for c: 70
Enter value for d: 80
old 1: insert into muthu values('&a','&b','&c','&d','pass')
new 1: insert into muthu values('102','Raja','70','80','pass')
1 row created.
SQL> insert into muthu values('&a','&b','&c','&d','pass');
Enter value for a: 103
Enter value for b: Sharin
Enter value for c: 70
-
8/10/2019 Lab Manual3
31/118
31
SEC CSE/IV DBMS LAB MANUAL
Enter value for d: 90
old 1: insert into muthu values('&a','&b','&c','&d','pass')
new 1: insert into muthu values('103','Sharin','70','90','pass')
1 row created.
SQL> insert into muthu values('&a','&b','&c','&d','pass');
Enter value for a: 104
Enter value for b: sam
Enter value for c: 90
Enter value for d: 95
old 1: insert into muthu values('&a','&b','&c','&d','pass')
new 1: insert into muthu values('104','sam','90','95','pass')
1 row created.
SQL> select * from muthu;
REGNO NAME MARK2 MARK3 RESULT
---------- ----------- ---------- ---------- ---------------------------------------
101 john 89 80 pass
102 Raja 70 80 pass
103 Sharin 70 90 pass
104 sam 90 95 pass
SQL> select * from muthu where name in (select name from kavi where mark2='70');
-
8/10/2019 Lab Manual3
32/118
32
SEC CSE/IV DBMS LAB MANUAL
103 Sharin 70 90
SQL> insert into muthu values('&a','&b','&c','&d','&e');
Enter value for a: 101
Enter value for b: john
Enter value for c: 90
Enter value for d: 90
Enter value for e: pass
old 1: insert into muthu values('&a','&b','&c','&d','&e')
new
1: insert into muthu
values('101','john','90','90','pass')
1 row created.
SQL> insert into muthu values('&a','&b','&c','&d','&e');
Enter value for a: 102
Enter value for b: raj
Enter value for c: 96
Enter value for d: 95
Enter value for e: pass
old 1: insert into muthu values('&a','&b','&c','&d','&e')
new 1: insert into muthu values('102','raj','96','95','pass')
REGNO NAME MARK2 MARK3 RESULT
---------- ----------- ---------- ---------- ---------------------------------------
102 Raja 70 80 pass
-
8/10/2019 Lab Manual3
33/118
33
SEC CSE/IV DBMS LAB MANUAL
1 row created.
SQL> insert into muthu values('&a','&b','&c','&d','&e'); Enter value for a: 103
Enter value for b: sam Enter value for c: 98
Enter value for d: 97
Enter value for e: pass
old1: insert into muthuvalues('&a','&b','&c','&d','&e')
ne
w
1: insert into muthuvalues('103','sam','98','97','pass')
1 rowcreated.
SQL> insert into muthuvalues('&a','&b','&c','&d','&e');
Enter value for a: 104
Enter value for b: sharin
Enter value for c: 95
Enter value for d: 90
Enter value for e: pass
old 1:insert into muthuvalues('&a','&b','&c','&d','&e')new
1:
insert
into muthuvalues('104','sharin','95','90','pass')
1 rowcreated.
SQL> select * frommuthu;SQL> descmuthu2
Name Null? Type
----------------------------------------- -------- ----------------------------
NAME VARCHAR2(11)
GRADE VARCHAR2(3)
-
8/10/2019 Lab Manual3
34/118
34
SEC CSE/IV DBMS LAB MANUAL
SQL> insert into muthu2 values('&a','&b');
Enter value for a: john
Enter value for b: s
old 1: insert into muthu2 values('&a','&b')
new 1: insert into muthu2 values('john','s')
1 row created.
SQL> insert into muthu2 values('&a','&b');
Enter value for a: raj
Enter value for b: s
old 1: insert into muthu2 values('&a','&b')
new 1: insert into muthu2 values('raj','s')
1 row created.
SQL> insert into muthu2 values('&a','&b');
Enter value for a: sam
Enter value for b: a
old 1: insert into muthu2 values('&a','&b')
new 1: insert into muthu2 values('sam','a')
1 row created.
SQL> insert into muthu2 values('&a','&b');
Enter value for a: sharin
-
8/10/2019 Lab Manual3
35/118
35
SEC CSE/IV DBMS LAB MANUAL
Enter value for b: a
old 1:insert into muthu2 values('&a','&b')
new 1: insert into muthu2 values('sharin','a')
1 row created.
SQL> select * from muthu2;
NAME GRA
----------- ----------
ohn s
raj s
sam a
sharin a
SQL> select muthu.name,muthu2.grade
2 from muthu inner join muthu2 on muthu.name=muthu2.name;
NAME GRA
----------- ---------
john s
raj s
sam a
sharin a
SQL> insert into muthu values('&a','&b','&c','&d','&e');
Enter value for a: 105
Enter value for b: smith Enter value for c: 90
-
8/10/2019 Lab Manual3
36/118
36
SEC CSE/IV DBMS LAB MANUAL
Enter value for d: 98
Enter value for e: pass
old 1: insert into muthu values('&a','&b','&c','&d','&e')
new 1: insert into muthu values('105','smith','90','98','pass')
1 row created.
SQL> SELECT * FROM MUTHU;
REGNO NAME MARK2 MARK3 RESULT
---------- ----------- ---------- ---------- -----------------------------------------
101 JOHN 90 90 PASS
102 RAJ 96 95 PASS
103 SAM 98 97 PASS
104 SHARIN 95 90 PASS
105 SMITH 90 98 PASS
SQL> select muthu.name,grade
2 from muthu left outer join muthu2 on muthu.name=muthu2.name;
NAME GRA
----------- ----------
ohn s
raj s
sam a
sharin a
smith null
-
8/10/2019 Lab Manual3
37/118
37
SEC CSE/IV DBMS LAB MANUAL
SQL> select muthu.name,regno,result from muthu right outer join muthu2 on
muthu.name=muthu2.name;
NAME REGNO RESULT
----------- ---------- --------------------------
ohn 101 pass
raj 102 pass
sam 103 pass
sharin 104 pass
RESULT:
The Nested Queries and join Queries using above commands have been executed and the output for
queries are as displayed .
VIVA QUESTION AND ANSWER
1. Define query language?
A query is a statement requesting the retrieval of information. The portion of DML that involves
information retrieval is called a query language
2. What is the use of sub queries?
A sub query is a select-from-where expression that is nested with in another query. A common use of sub
queries is to perform tests for set membership, make set comparisons, and determine set cardinality
POSSIBLE QUESTIONS
Create a student table with required fields and work nested queries.
-
8/10/2019 Lab Manual3
38/118
38
SEC CSE/IV DBMS LAB MANUAL
EX.NO:4
DATE: Views
DESCRIPTION
A VIEW is a virtual table, defined by a query, that does not exist until it is invoked by
name in an SQL statement. This may sound simple enough, but some developers have
difficulties with the concept. Because of this, they tend to leave out VIEWs because they do not
appreciate their value. It is easy to write a query and not bother to put it into a VIEW, because
there is no performance boost. 'If I am going to save code,' they reason, 'I want it in a stored
procedure that can take a parameter list instead.'
In fact, a VIEW definition can be copied as in-line text, just like a CTE. But with a good
optimizer, the SQL engine can decide that enough sessions are using the same VIEW and
materialize it as a shared table. The CTE, in contrast, is strictly local to the statement in which it
is declared.
VIEWs are often named incorrectly. A VIEW is a table, so it is named just like any other
table. The name tells us what set of things it represents in the data model. The most commonoffender is the Volkswagen coder who prefixes or suffixes the VIEW name with vw_ or
VIEW_ in violation of ISO-11179 rules. We do not mix data and meta data in a name. This is
as silly as prefixing every noun in a novel with n_ so the reader will know that the word is a
noun in English grammar.
The ANSI Standard SQL syntax for the VIEW definition is
CREATE VIEW [()]
AS
[WITH [] CHECK OPTION]
-
8/10/2019 Lab Manual3
39/118
39
SEC CSE/IV DBMS LAB MANUAL
::= CASCADED | LOCAL
the WITH CHECK OPTION is a little known and less used feature that has been around since
the SQL-86 Standards. The option in the WITH CHECK OPTION did not existin Standards before SQL-92. It is not implemented in T-SQL dialect, so I will skip it. If you see
it, just remember T-SQL defaults to CASCADED behavior.
A VIEW has no physical existence in the database until it is invoked. You cannot put constraints on a
VIEW for that reason. The name of the VIEW must be unique within the entire database schema, like a
base table name. The VIEW definition cannot reference itself, since it does not exist yet. Nor can the
definition reference only other VIEWs; the nesting of VIEWs must eventually resolve to underlying base
tables.
OBJECTIVE :
To create and manipulate various database objects of the Table using views
REQUIREMENTS AND ITS EXECUTION:
S.No. Facilities
required
Quantity
1 System 1
2 OS Oracle 9i
Algorithm:
1. Create a table.2. DML commands are Insert,Select,Update,Delete.3. The retrieval of information stored in the database.The insertion of new
information into the database4. The deletion of information from the database.The modification of information stored in
the database5. Execute the commands
-
8/10/2019 Lab Manual3
40/118
40
SEC CSE/IV DBMS LAB MANUAL
QUERY
VIEW
SQL> CREATE VIEW STU1_VIEW1(SNAME,DEPT) AS SELECT SNAME,DEPT FROM
STU1; View created.
SQL> SELECT * FROM STU1_VIEW1;
SNAME DEPT
------------ ---------
MANO MCA
DIVYA MCA
HARISH BE
BALA BE
Vinu BE
NISHA BE
MADHU MCA
SANJU BE
KRISH MCA
9 rows selected.
SQL> UPDATE STU1_VIEW1 SET DEPT='MCA' WHERE SNAME='Vinu';
1 row updated.
SQL> SELECT * FROM STU1_VIEW1;
-
8/10/2019 Lab Manual3
41/118
41
SEC CSE/IV DBMS LAB MANUAL
SNAME DEPT
----------- --------
MANO MCA
DIVYA MCA
HARISH BE
BALA BE
Vinu MCA
NISHA BE
MADHU MCA
SANJU BE
KRISH MCA
9 rows selected.
SQL> DELETE FROM STU1_VIEW1 WHERE
SNAME='SANJU'; 1 row deleted.
SQL> SELECT * FROM STU1_VIEW1;
SNAME DEPT
---------- -------
MANO MCA
DIVYA MCA
HARISH BE
BALA BE
Vinu MCA
NISHA BE
-
8/10/2019 Lab Manual3
42/118
42
SEC CSE/IV DBMS LAB MANUAL
MADHU MCA
KRISH MCA
8 rows selected.
SQL> DROP VIEW STU1_VIEW1;
View dropped.
SQL> CREATE VIEW STU1_V1 AS SELECT COUNT(RNO)
NOOFSTUDENTS,SUM(TMARKS)TOTAL FROM STU1
View created.
SQL> SELECT * FROM STU1_V1;
NOOFSTUDENTS TOTAL
----------------------- ----------
8 3526
SQL> CREATE TABLE STUDENT10(NAME VARCHAR2(10),REGNO NUMBER(10),MARK
NUMBER(3),PRIMARY KEY(REGNO)
Table created.
SQL> CREATE TABLE STUDENT2(REGNO NUMBER(10) PRIMARY KEY,NAME
VARCHAR(15),ADDRESS VARCHAR(20),FOREIG
N KEY(REGNO) REFERENCES STUDENT10(REGNO));
Table created.
SQL> INSERT INTO STUDENT10 VALUES('&NAME',®NO,&MARK)
Enter value for name: HARI
-
8/10/2019 Lab Manual3
43/118
43
SEC CSE/IV DBMS LAB MANUAL
1 row created.
SQL> SELECT * FROM STUDENT10;NAME REGNO MARK
--------- ---------- ----------
HARI 123 89
JANI 456 90
VISHNU 654 87
SQL> INSERT INTO STUDENT2 VALUES(®NO,'&NAME','&ADDRESS');
Enter value for regno: 123
Enter value for name: HARI
Enter value for address: MAIN RD,SALEM
old1: INSERT INTO STUDENT2VALUES(®NO,'&NAME','&ADDRESS')
new
1: INSERT INTO STUDENT2 VALUES(123,'HARI','MAINRD,SALEM')
1 row created.
SQL> SELECT * FROM STUDENT2;
REGNO NAME ADDRESS
---------- --------- --------------
123 HARI MAIN RD,SALEM
-
8/10/2019 Lab Manual3
44/118
44
SEC CSE/IV DBMS LAB MANUAL
View created.
SQL> SELECT * FROM STUVIEW;
REGNO NAME ADDRESS
---------- -------- -------------
123 HARI MAIN RD,SALEM
456 JANI FIRST CRS,NKL
654 VISHNU GANDHI ST,NKL
SQL> UPDATE STUVIEW SET ADDRESS='SECOND ST,NKL' WHERE REGNO=456
1 row updated.
SQL> SELECT * FROM STUVIEW;
REGNO NAME ADDRESS
---------- --------- --------------
123 HARI MAIN RD,SALEM
456 JANI SECOND ST,NKL
654 VISHNU GANDHI ST,NKL
RESULT:
The database objects of the Table using views has been executed
-
8/10/2019 Lab Manual3
45/118
45
SEC CSE/IV DBMS LAB MANUAL
VIVA QUESTION AND ANSWER
1. What is view in SQL? How is it defined?
Any relation that is not part of the logical model, but is made visible to a user as a virtual relation is
called a view. We define view in SQL by using the create view command. The form of the create view
command is Create view v as
-
8/10/2019 Lab Manual3
46/118
46
SEC CSE/IV DBMS LAB MANUAL
EX.NO:5(A)
DATE:
Procedures
DESCRIPTION:
Procedure is similar to functions but it wnt return any
values. Example are as follows.,
SQL> create table store(code varchar(15),name varchar(15),qty number,price
number); Table created.
SQL> desc store;
Name Null? Type
------------------------------- -------- ----
CODE VARCHAR2(15)
NAME VARCHAR2(15)
QTY NUMBER
PRICE NUMBER
INSERT PROCEDURE:
SQL> ed v;
create or replace procedure iiadd(v1 varchar,v2 varchar,v3 number,v4 number) as
pcode varchar(15);
pname varchar(15);
pqty number; pprice
number;
-
8/10/2019 Lab Manual3
47/118
47
SEC CSE/IV DBMS LAB MANUAL
begin
pcode:=v1;
pname:=v2;
pqty:=v3;
pprice:=v4;
insert into store values(pcode,pname,pqty,pprice);
end;
SQL> @ v;
13 /
Procedure created.
To Execute Procedure:
SQL> exec iiadd('p','book',20,700);
PL/SQL procedure successfully completed.
SQL> select * from store;
CODE NAME QTY PRICE
--------------- --------------- --------- ---------
p book 20700
SQL> exec iiadd('q','pen',60,800);
PL/SQL procedure successfully completed.
SQL> exec iiadd('r','scale',40,100);
PL/SQL procedure successfully completed.
SQL> select * from store;
-
8/10/2019 Lab Manual3
48/118
48
SEC CSE/IV DBMS LAB MANUAL
CODE NAME QTY PRICE
--------------- --------------- --------- ---------
p book 20 700
q pen 60 800
r scale 40 100
2.DELETE PROCEDURE:
SQL> ed p;
create or replace procedure iidel(v1 varchar) as
pcode varchar(15);
begin
pcode:=v1;
delete from store where code=pcode;
dbms_output.put_line('record
deleted'); end;
SQL> @ p;
8 /
Procedure created.
To Execute Procedure:
SQL> exec iidel('r');
record deleted
PL/SQL procedure successfully completed.
SQL> select * from store;
CODE NAME QTY PRICE
-
8/10/2019 Lab Manual3
49/118
49
SEC CSE/IV DBMS LAB MANUAL
--------------- --------------- --------- ---------
p book 20 700
q pen 60 800
3.SELECT AND UPDATE PROCEDURE:
SQL> ed u;
create or replace procedure iiup(v1 varchar,v2 number)
as pcode varchar(15);
price1 number;
prprice number;
begin
pcode:=v1;
price1:=v2;
select price1 into prprice from store where code=pcode;
update store set price=prprice where code=pcode;
dbms_output.put_line('record updated successfully');
end;
SQL> @
u; 12 /
Procedure created.
To Execute Procedure:
SQL> exec iiup('p',600);
record updated successfully
-
8/10/2019 Lab Manual3
50/118
50
SEC CSE/IV DBMS LAB MANUAL
PL/SQL procedure successfully completed.
SQL> select * from store;
CODE NAME QTY PRICE
--------------- --------------- --------- ---------
p book 20 600
q pen 60 800
OBJECTIVE :
To create a PL/SQL program to find Largest of three number using control structure
S.No. Facilities
required
Quantity
1 System 1
2 OS Oracle 9i
Algorithm:
1. Start the process
2. Declare appropriate variable
3. Using if statement and compare the given value.
4. Display the result.5. Stop the process
-
8/10/2019 Lab Manual3
51/118
51
SEC CSE/IV DBMS LAB MANUAL
QUERY
SQL>SET SERVER OUTPUT ON;
SQL> 1 DECLARE
2 A NUMBER;
3 B NUMBER;
4 C Numbers;
5 BEGIN
6 A:=&A;
7 B:=&B;
8 C:=&C;
9 IF A>B THEN
10 IF A>C THEN
11 DBMS_OUTPUT.PUT_LINE ('BIGGEST IS:'
||TO_CHAR(A)); 12 ELSE
13 DBMS_OUTPUT.PUT_LINE('BIGGEST IS :'
||TO_CHAR(C)); 14 END IF;
15 ELSIF B>C THEN
16 DBMS_OUTPUT.PUT_LINE('BIGGEST IS :'
||TO_CHAR(B)); 17 ELSE
18 DBMS_OUTPUT.PUT_LINE('BIGGEST IS :'
||TO_CHAR(C)); 19 END IF;
20 ENDS; SQL> /
-
8/10/2019 Lab Manual3
52/118
-
8/10/2019 Lab Manual3
53/118
53
SEC CSE/IV DBMS LAB MANUAL
POSSIBLE QUESTIONS:
1. Create a view to implement employee details.
2. Create a view to implement librarydetails
3. Create a view to implement student details
-
8/10/2019 Lab Manual3
54/118
54
SEC CSE/IV DBMS LAB MANUAL
EX.NO:5(b)
DATE:
Functions
DESCRIPTION:
Functions are similar to procedures. But will return values.
SINGLE LINE FUNCTIONS:
It returns one row of result for each request.
TYPES OF SINGLE LINE FUNCTIONS:
-----------------------------------------------------
The following are the types of single line functions
Numeric functions
String functions
Date functions
List functions
Conversion functions
OBJECTIVE:
To write a PL/SQL program using functions.
REQUIREMENTS AND ITS EXECUTION:
S.No. Facilities
required
Quantity
1 System 1
2 OS Oracle 9i
-
8/10/2019 Lab Manual3
55/118
55
SEC CSE/IV DBMS LAB MANUAL
Algorithm:
1. Start the program.
2. Declare the variable a,b,c with integer type3. Read the value of a f
4. Call the function f1
5. Print c, will display the result
6. Stop the program
QUERY
SQL>CREATE OR REPLACE FUNCTION FAC(N NUMBER) RETURN NUMBER IS
2 F NUMBER:=1;
3 BEGIN
4 FOR I IN 1..N
5 LOOP
6 F:=F*I;
7 END LOOP;
8 RETURN F;
9 END;
Function created.
SQL> DECLARE
2 A NUMBER:=&A;
3 B NUMBER;
-
8/10/2019 Lab Manual3
56/118
56
SEC CSE/IV DBMS LAB MANUAL
4 BEGIN
5 B:=FAC(A);
6 DBMS_OUTPUT.PUT_LINE('FACTORIAL OF GIVEN NUMBER IS::'||B);
7 END;
8 /
Enter value for a: 5
Old 2: A NUMBER: =&A;
New 2: A NUMBER: =5;
PL/SQL procedure successfully completed.
SQL> SET SERVEROUTPUT ON;
SQL> /
Enter value for a: 5
Old 2: A NUMBER:=&A;
New 2: A NUMBER:=5;
FACTORIAL OF GIVEN NUMBER IS::120
PL/SQL procedure successfully completed.
RESULT:
The PL/SQL program using functions has been executed .
-
8/10/2019 Lab Manual3
57/118
-
8/10/2019 Lab Manual3
58/118
58
SEC CSE/IV DBMS LAB MANUAL
EX.NO:5(C)
DATE:
Control Structures
Descripition:
The structure of the the PL/SQL IF statement is similar to the structure of IF statements in otherprocedural languages .It allows PL/SQL to perform actions selectively based on conditions.
There are three forms of IF statements:
IF-THEN-END IF
IF-THEN-ELSE-END IF IF-THEN-ELSIF-END IF
Syntax:
IF condition THENStatements;[ELSIF condition THENStatements;][ELSEStatements;]
if then
OBJECTIVE:
To write a PL/SQL program to find the sum of two number using control structures.
REQUIREMENTS FOR EXECUTIONS:
S.No. Facilities
required
Quantity
1 System 1
2 OS Turboc
-
8/10/2019 Lab Manual3
59/118
59
SEC CSE/IV DBMS LAB MANUAL
Algorithm:
1. Start the program
2. Declare the variable a,b,c with integer data type
3. Read the values of a,b.
4. Pass the values to create the procedure
5. Print c to display the result
6. Stop the program
QUERY
Simple Loop:
SQL> declare
2 a number:=100;
3 begin
4 loop
5 a:=a+25;
6 exit when a=250;
7 dbms_output.put_line(a);
8 end loop;
9 end;
10 /
125
150
175
-
8/10/2019 Lab Manual3
60/118
60
SEC CSE/IV DBMS LAB MANUAL
200
225
PL/SQL procedure successfully completed.
While Loop:
SQL> declare
2 a number:=100;
3 begin
4 while a
-
8/10/2019 Lab Manual3
61/118
61
SEC CSE/IV DBMS LAB MANUAL
For Loop:
SQL> declare
2 a number:=100;
3 begin
4 for i in 1..5
5 loop
6 a:=a+25;
7 dbms_output.put_line(a);
8 end loop;
9 end;
10 /
125
150
175
200
225
PL/SQL procedure successfully completed.
-
8/10/2019 Lab Manual3
62/118
62
SEC CSE/IV DBMS LAB MANUAL
If then:
SQL> declare
2 a number:=100;
3 begin
4 if a>100 then
5 a:=a-50;
6 else
7 a:=a+50;
8 end if;
9 dbms_output.put_line(a);
10 end;
11 /
150
PL/SQL procedure successfully completed.
RESULT:
Thus the PL/SQL program for control structures has been executed
VIVA QUESTION AND ANSWER
1. Define Partial Functional Dependency. (A.U May/June 2010)
A FD x y is a partial dependency if some attribute A x can be removed from x and the dependency
still holds; i.e., for some A x, ( x { A } ) y
-
8/10/2019 Lab Manual3
63/118
63
SEC CSE/IV DBMS LAB MANUAL
2. Define transaction-processing systems.
The concept of transaction provides a mechanism for describing logical units or database processing.
Transaction-processing systems are systems with large databases and many concurrent users work with
those systems.
3. Define read only transaction.
The database operations in a transaction do not update the database but only retrieve data and that
transaction is called a read-only transaction.
POSSIBLE QUESTIONS
1. Write a PL/SQL program to find the largest number using control structure
2. Write a PL/SQL program to find the smallest number using control structure
3. Write a PL/SQL program to find the fibonacci number using control structure.
-
8/10/2019 Lab Manual3
64/118
64
SEC CSE/IV DBMS LAB MANUAL
EX.NO:6
DATE:
Front End Tools
Description:1. Start Programs Developer 2000 R 2.0Form builder Enter.2. The following wizard will open.
3. Click the button OK.
4. The following wizard will open.
5. Click NEXT New wizard openchoose TABLE OR VIEW click NEXT.
6. Following wizard will open.
-
8/10/2019 Lab Manual3
65/118
65
SEC CSE/IV DBMS LAB MANUAL
59
-
8/10/2019 Lab Manual3
66/118
66
SEC CSE/IV DBMS LAB MANUAL
7. Click BrowseWizard will open
8. Click Connect Wizard openChoose CURRENT USER & TABLE.9. Click OKWizard open.
10. Choose your tableClick OK.11. Move the available column to Database using the button >>.12. ClickNEXT.
13. New wizard openChoose one optionClick FINISH.14. New wizard openClick NEXT.15. New wizard openClick NEXT.16. Move the available column to Database using the button >>.
17. . Click NEXT
New wizard will open.
-
8/10/2019 Lab Manual3
67/118
67
SEC CSE/IV DBMS LAB MANUAL
18. Layout Wizard open
Choose FORM
Click NEXT
Give Title of frame.
19. Wizard open
Click FINISH
Now the following Design window will open.
20. Layout Wizard open
Choose FORM
Click NEXT
Give Title of frame.
21. Wizard open
Click FINISH
Now the following Design window will open.
-
8/10/2019 Lab Manual3
68/118
68
SEC CSE/IV DBMS LAB MANUAL
22. We will now create 4 push buttons and write triggers for each button.
23. We will change the label of the push buttons in the property palette to "View, Insert, Clear andDelete." To do this, right click on the button and go to its Property Palette
22. Create Alerts (a modal window) on a push button that will function as a warning or a message to
the users when they click the button.
23. Create Procedures which are stored blocks of code which can be called from multiple objects
saving the time taken for retyping codes.
-
8/10/2019 Lab Manual3
69/118
69
SEC CSE/IV DBMS LAB MANUAL
OBJECTIVE :
To create a front end tools using form builder 2000.
REQUIREMENTS AND ITS EXECUTION:
S.No. Facilities
required
Quantity
1 System 1
2 OS Oracle 9i
Algorithm:
1. Start Programs Developer 2000 R 2.0Form builder Enter
2. Click the button OK.
3. Click NEXTNew wizard openchoose TABLE OR VIEW click NEXT.
4. Click BrowseWizard will open
5. Click Connect Wizard openChoose CURRENT USER&TABLE. Choose your
tableClick OK.Move the available column to Database using the button >>.ClickNEXT.
6. New wizard openChoose one optionClick FINISH.New wizard openClick NEXT.New
wizard openClick NEXT.Move the available column to Database using the button >>.Click
NEXT New wizard will open.
7. Layout Wizard openChoose FORM Click NEXT Give Title of frame.Wizard openClick
FINISH Now the following Design window will open
8. We will now create 4 push buttons and write triggers for each button
We will change the label of the push buttons in the property palette to
View, Insert, Clear and Delete." To do this, right click on the button
and go to its Property Palette.
9. Create Alerts (a modal window) on a push button that will function as a
warning or a message to the users when they click the button. Create
Procedures which are stored blocks of code which can be called from
multiple objects saving the time taken for retyping codes.
-
8/10/2019 Lab Manual3
70/118
70
SEC CSE/IV DBMS LAB MANUAL
Creating an Alert
1.Go to Alerts in the Object Navigator and double click on it.
2. Double click on the newly created alert and name it DELETE_ALERT.
3. Now double click on the alert and you will immediately go to its Property Palette. In the
properties:
Change the title of the alert to Delete Alert
Type in the message as "Are you sure you want to Delete?"
Select Stop as the Alert style
You can add a third button to the alert or just keep the OK and Cancel
Make sure that Button1 is selected as the default button
4.To activate the alert, we will create a procedure which we will call from the delete button. To add aprocedure, go to the Object Navigator and double click on Program Units. Immediately the window for thenew Program unit will appear
-
8/10/2019 Lab Manual3
71/118
71
SEC CSE/IV DBMS LAB MANUAL
5. In the window for the new Program Unit, type in the name as Delete-Alert. Make sure that
procedure is selected as the type of Program Unit and click OK.
6. Once you click OK, you will be automatically taken to the PL/SQL Editor window. In the
PL/SQL Editor, type the code for activating the alert( delete_alert).
7. We will now add a push button to the form and then add the procedure to it, so that whenever the
user clicks on delete, the alert will be shown.
24. Now select the PL/SQL editor by right clicking on the push button & Write appropriate PL/SQL
code in the blank space of the editor and then click Compile.
RESULT:
The front end tools has been executed to give results as above.
Viva Questions :
1.What is Domain-Key Normal Form?A relation is said to be in DKNF if all constraints and dependencies that should hold on the theconstraint can be enforced by simply enforcing the domain constraint and key constraint on therelation.
2. What are partial, alternate,, artificial, compound and natural key?1. Partial Key: It is a set of attributes that can uniquely identify weak entities and that are
-
8/10/2019 Lab Manual3
72/118
72
SEC CSE/IV DBMS LAB MANUAL
related to same owner entity. It is sometime called as Discriminator.
2. Alternate Key: All Candidate Keys excluding the Primary Key are known as AlternateKeys
3. Artificial Key: If no obvious key, either stand alone or compound is available, then the lastresort is to simply create a key, by assigning a unique number to each record or occurrence.Then this is known as developing an artificial key.4. Compound Key: If no single data element uniquely identifies occurrences within aconstruct,then combining multiple elements to create a unique identifier for the construct is known ascreating a compound key.
5. Natural Key: When one of the data elements stored within a construct is utilized as theprimary key, then it is called the natural key.
3. What is indexing and what are the different kinds of indexing?
Indexing is a technique for determining how quickly specific data can be found.Types:1. Binary search style indexing2. B-Tree indexing3. Inverted list indexing4. Memory resident table
Possible Questions:
1. Using the tools create MS.ascess table for employees2. Develop an application to view the details of the customers.
-
8/10/2019 Lab Manual3
73/118
73
SEC CSE/IV DBMS LAB MANUAL
EX.NO:7
DATE:
FORMS
Description:
FORMS ARE GENERATED BY FOLLOWING STEPS:
1. Creating table using SQL Query.
2. Designing forms in Programs->Oracle Developer 2000 R 2.0 -> Form Builder.
3. Creating, saving forms in Form Object Navigator with the extension of ex1.fmb.
4. In Data Block Wizard, Connecting Oracle Database Table into Forms.
5. In Layout Wizard, Select the Data block field and to set its width and height of fields.
6. Layout Editor displayed the Form design with fields in terms of frames or tables.7. Compiling and Building forms using PL/SQL Compiler.
8. Enter the Query by using F7 and Executing Query by using F8 in Action Menu.
9. In Records Menu -> Insert, Remove Records are used.
10. Updating, select the fields to change and execute the query in Query menu.
11. Inserting, Displaying, Updating, Deleting Records using by Query in Forms and the results are
updated both forms and Oracle Database.
12. Rebuilt the forms and Closing the forms.
Objective:
To design and implement a form using visual basic.
Requirements for Execution:
S.No. Facilities
required
Quantity
1 System 1
2 OS Oracle 9i
-
8/10/2019 Lab Manual3
74/118
74
SEC CSE/IV DBMS LAB MANUAL
Algorithm:
1. Create a new project in VB
2. Place the control like Label, text box, Option button in form
3. Set the caption properties of labels to the required field name
4. Delete the default values of the text box
5. Double click the buttons and write the code for buttons
Coding:
Private Sub Form_Load( )
Me.WindowState=2
End Sub
Private Sub Option1_Click( )
If Option1.Value=True Then
Text3.Text=Val(Text1.Text]+Val(Text2.Text)
End Sub
Private Sub Option2_Click( )
If Option1.Value=True Then
Text3.Text=Val(Text1.Text]-Val(Text2.Text)
End Sub
Private Sub Option3_Click( )
If Option1.Value=True Then
Text3.Text=Val(Text1.Text]*Val(Text2.Text)
End Sub
-
8/10/2019 Lab Manual3
75/118
75
SEC CSE/IV DBMS LAB MANUAL
Private Sub Option4_Click( )
If Option1.Value=True Then
Text3.Text=Val(Text1.Text]/Val(Text2.Text)
End Sub
RESULT:
The form using visual basic has been executed to give results as above.
VIVA QUESTION AND ANSWER
1. Define safety of expression in tuple relational calculus. (A.U Nov/Dec 2010)
Query or expression { t | P(t)} is safe if all values that appear in the result are values from Dom(p), whereDom(p) is domain of P. Else it is unsafe. For example, the tuples selected in the tuple relational calculus
are unsafe.
2. Define domain relational calculus. (A.U Nov/Dec 2008)
Domain relational calculus uses domain variables that take on values from an attributes domain rather
than values for an entire tuple.An expression in the domain relational calculus is of the form{ | (P(x1,xn, xn))}where x1,xn, xn represents domain variables represents a formula composed of
atoms or domain variables.
POSSIBLE QUESTIONS
Create a project in VB for form design
.
-
8/10/2019 Lab Manual3
76/118
-
8/10/2019 Lab Manual3
77/118
-
8/10/2019 Lab Manual3
78/118
78
SEC CSE/IV DBMS LAB MANUAL
Table created.
SQL>CREATE TABLE CLIENT ( CLI_NO CHAR(7),NAMEVARCHAR2(10),BAL_DUE
NUMBER(10,2),OPER CHAR(8),USERID CHAR(20),ORDATE DATE);
Table created.
SQL> DESC MASTER;
Name Null? Type
-------- -------- -------
CLI_NO NOT NULL CHAR(7)
NAME NOT NULL VARCHAR2(10)
ACNO NUMBER(6)
ADDRESS VARCHAR2(30)
CITY VARCHAR2(10)
STATE VARCHAR2(10)
PIN NUMBER(6)
BAL_DUE NUMBER(10,2)
SQL> DESC CLIENT;
Name Null? Type
-------- ------- --------
CLI_NO CHAR(7)
NAME VARCHAR2(10)
BAL_DUE NUMBER(10,2)
-
8/10/2019 Lab Manual3
79/118
79
SEC CSE/IV DBMS LAB MANUAL
OPER CHAR(8)
USERID CHAR(20)
ORDATE DATE
TRIGGER AFTER UPDATE OR DELETE
SQL> CREATE OR REPLACE TRIGGER UPDATE_TRI AFTER UPDATE OR DELETE ON
MASTER
2 FOR EACH ROW
3 DECLARE
4 CLI_NO CHAR(7);
5 OPER CHAR(8);
6 NAME VARCHAR(10);
7 BAL_DUE NUMBER(10,2);
8 BEGIN
9 IF UPDATING THEN
10 OPER:='UPDATE';
11 END IF;
12 IF DELETING THEN
13 OPER:='DELETE';
14 END IF;
15 CLI_NO:=:OLD.CLI_NO;
16 NAME:=:OLD.NAME;
17 BAL_DUE:=:OLD.BAL_DUE;
18 INSERT INTO CLIENT
-
8/10/2019 Lab Manual3
80/118
80
SEC CSE/IV DBMS LAB MANUAL
19 VALUES(CLI_NO,NAME,BAL_DUE,OPER,USER,SYSDATE);19 END;
20 /
Trigger created.
TRIGGER BEFORE INSERT
SQL>CREATE OR REPLACE TRIGGER TRI_INSERT BEFORE INSERT ON
MASTER 2 FOR EACH ROW
3 DECLARE
4 NEW_NO CHAR(7);
5 CLI_NO CHAR(7);
6 NAME VARCHAR(10);
7 ADDRESS VARCHAR2(30);
8 CITY VARCHAR2(10);
9 STATE VARCHAR(10);
10 PIN NUMBER(6);
11 BAL_DUE NUMBER(10,2);
12 BEGIN
13 NEW_NO:=:NEW.CLI_NO;
14 IF NEW_NO LIKE 'C%' THEN
15 DBMS_OUTPUT.PUT_LINE('RECORD ADDED SUCCESSFULLY');
16 ELSE
17 RAISE_APPLICATION_ERROR(-20002,'NAME SHOULD START WITH C');
18 END IF;
-
8/10/2019 Lab Manual3
81/118
81
SEC CSE/IV DBMS LAB MANUAL
19 END;
20 /
Trigger created.
SQL>INSERT INTO MASTERVALUES('&CLI_NO','&NAME',&ACNO,'&ADDRESS','&CITY','&STATE',&PIN,&BAL_D
UE);
Enter value for cli_no: C01
Enter value for name:
MALAR Enter value for
acno: 100
Enter value for address:
10,MAIN ST Enter value for
city: NKL
Enter value for state: TN
Enter value for pin:
637015 Enter value for
bal_due: 10000
Old 1: INSERT INTO MASTER
VALUES('&CLI_NO','&NAME',&ACNO,'&ADDRESS','&CITY','&STATE',&PIN,&BAL_DU
E
New1: INSERT INTO MASTERVALUES('C01','MALAR',100,'10,MAIN
ST','NKL','TN',637015,10000)
RECORD ADDED
SUCCESSFULLY 1 row created.
-
8/10/2019 Lab Manual3
82/118
82
SEC CSE/IV DBMS LAB MANUAL
SQL> /
Enter value for cli_no:
C02 Enter value for
name: MANO Enter
value for acno: 101
Enter value for address: 17,GANDHI STEnter value for city: CHENNAI
Enter value for state: TN
Enter value for pin: 600001
Enter value for bal_due: 3000
Old 1: INSERT INTO MASTER
VALUES('&CLI_NO','&NAME',&ACNO,'&ADDRESS','&CITY','&STATE',&PIN,&BAL_DUE
New 1: INSERT INTO MASTERVALUES('C02','MANO',101,'17,GANDHI
ST','CHENNAI','TN',600001,3000)
RECORD ADDED
SUCCESSFULLY 1 row created.
SQL> /
Enter value for cli_no:
A100 Enter value for
name: JANU Enter value
for acno: 103
Enter value for address: 12,FIRST
CROSS Enter value for city: TRICHY
-
8/10/2019 Lab Manual3
83/118
83
SEC CSE/IV DBMS LAB MANUAL
Enter value for state: TN
Enter value for pin:
635606 Enter value for
bal_due: 3400
Old 1: INSERT INTO MASTER
VALUES('&CLI_NO','&NAME',&ACNO,'&ADDRESS','&CITY','&STATE',&PIN,&BAL_DU
E
new 1: INSERT INTO MASTER VALUES('A100','JANU',103,'12,FIRST
CROSS','TRICHY','TN',635606,3400)
INSERT INTO MASTER VALUES('A100','JANU',103,'12,FIRST
CROSS','TRICHY','TN',635606,3400)
ERROR at line 1:
ORA-20002: NAME SHOULD START WITH C
ORA-06512: at "SCOTT.TRI_INSERT", line 15
ORA-04088: error during execution of trigger 'SCOTT.TRI_INSERT'
SQL> SELECT * FROM MASTER;
CLI_NO NAME ACNO ADDRESS CITY STATE PIN BAL_DUE
------- ---------- --------- --------------- ------- ---------- --------------------
C01 MALAR 100 10,MAIN ST NKL TN 637015 10000
C02 MANO 101 17,ANNA ST CHENNAITN 600001 3000
SQL> UPDATE MASTER SET BAL_DUE=BAL_DUE-1000 WHERE
CLI_NO='C01'; 1 row updated.
-
8/10/2019 Lab Manual3
84/118
84
SEC CSE/IV DBMS LAB MANUAL
SQL> SELECT * FROM MASTER;
CLI_NO NAME ACNO ADDRESS CITY STATE PIN BAL_DUE
------- ---------- -------- ---------------- ------- ---------- ----- --------------
C01 MALAR 100 10,MAIN ST NKL TN 637015 9000
C02 MANO 101 17,GANDHI STCHENNAI TN 600001 3000
RESULT:
The trigger for various operation on master table maintained in a bank has been executed to giveresults as
above.
VIVA QUESTION AND ANSWER
1.What is the need for triggers?
Triggers are useful mechanisms for alerting humans or for starting certain tasks automatically when
certain conditions are met.
2. List the requirements needed to design a trigger.
The requirements are
Specifying when a trigger is to be executed.
Specify the actions to be taken when the trigger executes.
3. Give the forms of triggers?
The triggering event can be insert or delete.
For updated the trigger can specify columns.
The referencing old row as clause
-
8/10/2019 Lab Manual3
85/118
85
SEC CSE/IV DBMS LAB MANUAL
The referencing new row as clause
The triggers can be initiated before the event or after the event.
Possible Questions:
1.To write a PL/SQL program for trigger actions.(insert, delete ,update)
2. Write a PL/SQL program to calculate the mark list for each student using trigger
actions.(Insert and Update a record)
-
8/10/2019 Lab Manual3
86/118
86
SEC CSE/IV DBMS LAB MANUAL
EX.NO:9
DATE:
Menu Design
DESCRIPTION:
Menus are list of choices that are created by users by using form builders with connectivity ofdatabase.
Menus can be created by following procedure.
1. Menu Editor can create menus and menu items quickly and easily.
2. Start Form Builder; create a new menu module in the Object Navigator.
3. Replace the modules default name assigned by the navigator with name.
4. Save the newly created module to an appropriate directory in the file system.
5. In Oracle Menu Hierarchy, Menu modules - Like form modules, a menu
module can contain its own items (menus and menu items), program units and
other objects.
6. Menus - Including main menus, individual menus, and submenus.
7. Menu items
8. Creating a menu module ,Creating menus and menu items ,Assigning
commands to menu items9. Saving and generating (Compiling) the menu module (creates the .mmx file)
10. Attaching a menu module to a form.
OBJECTIVE :
To design and implement a menu design using Visual Basic
Requirements For Execution:
S.No. Facilitiesrequired
Quantity
1 System 1
2 OS Oracle 9i
-
8/10/2019 Lab Manual3
87/118
87
SEC CSE/IV DBMS LAB MANUAL
Algorithm:
1. Create a new project in VB
2. Place the controls like Labels , text boxes in form
3. Set the caption property of label to the required field name4. Delete the default values of the text box
5. Double click the buttons and write the code for buttons
Coding:
Dim unsavedchange As Boolean Dim
changed As Boolean
Private Sub mnubold_Click(Index As Integer)
RichTextBox1.SetBold = Not RichTextBox1.SelBold
End Sub
Private Sub mnucaps_Click(Index As Integer)
RichTextBox1.SelText = UCase(RichTextBox1.SelText)
End SubPrivate Sub mnucopy_Click(Index As Integer)
Clipboard.SetText RichTextBox1.SelRTF
End Sub
Private Sub mnucut_Click(Index As Integer)
Clipboard.SetText RichTextBox1.SelRTF
RichTextBox1.SelRTF = ""
End Sub
Private Sub mnudelete_Click(Index As Integer)
RichTextBox1.SelText = ""SEC CSE/IV DBMS LAB MANUAL
-
8/10/2019 Lab Manual3
88/118
88
SEC CSE/IV DBMS LAB MANUAL
End Sub
Private Sub mnuexit_Click(Index As Integer)
If unsavedchange=True then
If (MsgBox(would u like to save ur changes?,vbYesNo)) then
CommonDialog1.ShowSave
RichTextBox1.SaveFile CommonDialog1.FileName,rtRTF
End If
End If
RichTextBox1.Visible=False
End Sub
Private Sub mnufind_Click(Index As Integer)
Dim search As StringDim position As Integer
search = InputBox("Enter search word", "Find") If search
"" Then
position = RichTextBox1.Find(search, , , rtfWholeWord) If
position -1 Then
RichTextBox1.Span " ", True, True
Else
MsgBox "search string not found", , "find"
End If
End If
End Sub
-
8/10/2019 Lab Manual3
89/118
89
SEC CSE/IV DBMS LAB MANUAL
Private Sub mnufont_Click(Index As Integer)
CommonDialog1.ShowFont
RichTextBox1.SelFontName = CommonDialog1.FontName
RichTextBox1.SelFontSize = CommonDialog1.FontSize
RichTextBox1.SelColor = CommonDialog1.Color
RichTextBox1.SelBold = CommonDialog1.FontBold
RichTextBox1.SelItalic = CommonDialog1.FontItalic
RichTextBox1.SelUnderline = CommonDialog1.FontUnderline
RichTextBox1.SelStrikeThru = CommonDialog1.FontStrikethru
End SubPrivate Sub mnuitalic_Click(Index As Integer)
RichTextBox1.SelItalic = Not RichTextBox1.SelItalic End Sub
Private Sub mnunew_Click(Index As Integer)
RichTextBox1.Visible = True
RichTextBox1.Text = ""
RichTextBox1.SetFocus
End Sub
Private Sub mnunow_Click(Index As Integer)
RichTextBox1.Text = Now
End Sub
Private Sub mnuopen_Click(Index As Integer)
Dim filename As String
-
8/10/2019 Lab Manual3
90/118
90
SEC CSE/IV DBMS LAB MANUAL
CommonDialog1.Filter = "Text files (*.txt) | *.txt"
CommonDialog1.ShowOpen
filename = CommonDialog1.filename
RichTextBox1.LoadFile (filename) changed =
False
End Sub
Private Sub mnupaste_Click(Index As Integer)
RichTextBox1.SelRTF = Clipboard.GetText
End Sub
Private Sub mnuprint_Click(Index As Integer)RichTextBox1.SelPrint (Printer.hDC)
End Sub
Private Sub mnusave_Click(Index As Integer)
Dim filename As String
CommonDialog1.DefaultExt = ".txt"
CommonDialog1.Filter = "Text files (*.txt) | *.txt"
CommonDialog1.ShowSave
filename = CommonDialog1.filename
RichTextBox1.SaveFile (filename), rtfText changed
= False
End Sub
Private Sub mnusaveas_Click(Index As Integer)
CommonDialog1.ShowSave
-
8/10/2019 Lab Manual3
91/118
-
8/10/2019 Lab Manual3
92/118
92
SEC CSE/IV DBMS LAB MANUAL
POSSIBLE QUESTIONS
1. Create a project in VB for menu design
2. Create a project in VB for hotel food design
3. Create a project in VB for car showroom design
-
8/10/2019 Lab Manual3
93/118
93
SEC CSE/IV DBMS LAB MANUAL
EX.NO:10
DATE:
.
Reports
Description:
Reports can be generated by form builder in the way of graphs or charts. It can be created byfollowing
procedure.
1. Creating table using SQL Query.
2. Inserting Records using Queries.
3. Designing reports in Programs->Oracle Developer 2000 R 2.0 -> Report Builder.
4. First Step, Oracle Reports connect to an Oracle Server.
5. Reports having Data Model information about queries used for a report.
6. Define the Layout of the report including the overall orientation of Query Results.
7. Create any triggers or program units that will be executed with the report.
8. Reports having Web Source of web page or web service that returns a data set.
9. In Report Wizard are having choices like tabular, form, matrix, group, mailinglabels.
10. In Query Builder enter the SQL SELECT statement and also connect with import
SQL Query.
11. In addition, aggregate functions can also be applied to the fields on the report.
12. A design template can be applied that include specifications for fonts, colors and
layout of the report.
13. Finally the Reports Live Previewer will appear showing the report.
14. In File menu, saving, generating and running the report.
OBJECTIVE :
To generate salary report for employee department comes college wise.
-
8/10/2019 Lab Manual3
94/118
94
SEC CSE/IV DBMS LAB MANUAL
Requirements for execution:
S.No. Facilities
required
Quantity
1 System 1
2 OS Oracle 9i
Algorithm:
1. Create a table.
2. DML commands are Insert,Select,Update,Delete3. The retrieval of information stored in the database.The insertion of
new information into the database
4. The deletion of information from the database.The modification of
information stored in the database
5. Execute the commands
SOURCE CODE
TABLE CREATION
SQL>create c110(ccode number(5), cname varchar(15), dept char(10), sal(8,2));
INSERTING VALUES
SQL>insert into c110 values(&ccode,&cname,&dept,&sal);
Enter values for ccode: 10001
Enter values for cname: raj
Enter values for dept: mca
Enter values for sal: 20000
-
8/10/2019 Lab Manual3
95/118
95
SEC CSE/IV DBMS LAB MANUAL
Old 1:insert into c110 values(&ccode,&cname,&dept,&sal)
New 1:insert into c110 values(100001,raj,mca,20000)
1 row created.
SQL>/
Enter values for ccode: 10002
Enter values for cname: sakthi
Enter values for dept: be
Enter values for sal: 30000
Old 1:insert into c110 values(&ccode,&cname,&dept,&sal)
New 1:insert into c110 values(100002,sakthi,be,30000).
1 row created.
SQL>/
Enter values for ccode: 10003
Enter values for cname: sriram
Enter values for dept: mtech
Enter values for sal: 40000
Old 1:insert into c110 values(&ccode,&cname,&dept,&sal)
New 1:insert into c110 values(10003,sriram
,
mtech,40000)
1 row created.
-
8/10/2019 Lab Manual3
96/118
96
SEC CSE/IV DBMS LAB MANUAL
SQL>/
Enter values for ccode: 10004
Enter values for cname: arulbala
Enter values for dept: barch
Enter values for sal: 30000
Old 1:insert into c110 values(&ccode,&cname,&dept,&sal)
New 1:insert into c110 values(10004,arulbalaj,barch,30000)
1 row created.
SQL>/
Enter values for ccode: 10005
Enter values for cname: raguram
Enter values for dept: mca
Enter values for sal: 40000
Old 1:insert into c110 values(&ccode,&cname,&dept,&sal)
New 1:insert into c110 values(10005,raguram,mca,40000)
1 row created. SQL>select
* from c110;
-
8/10/2019 Lab Manual3
97/118
-
8/10/2019 Lab Manual3
98/118
-
8/10/2019 Lab Manual3
99/118
99
SEC CSE/IV DBMS LAB MANUAL
3. What are the goals of database tuning?
The goals of database tuning are:
To make applications run faster. To lower the response time of queries/transactions.
To improve the overall throughput of transactions.
POSSIBLE QUESTIONS
1 . Create a report to implement employee details.
2. Create a report to implement college details.
3. Create a report to implement population of a place details.
-
8/10/2019 Lab Manual3
100/118
100
SEC CSE/IV DBMS LAB MANUAL
EX.NO:11(a)
DATE:
Database Design And Implementation(Mini Project)
Description:
To design a project (or) form using virtual basic as a front end tools and micro soft acess as aback.
Objective:
To design and implement a payroll processing using visual Basic
Requirements for execution:
S.No. Facilitiesrequired
Quantity
1 System 1
2 OS Oracle 9i
Algorithm:
1. The table of the given database are identified along with their attributes
and they are created
2. Create database using access and insert some values into them
3. Create a new project in VB
4. Place the controls like Labels , text boxes in form
5. Set the caption property of label to the required field name
6. Delete the default values of the text box
7. Double click the buttons and write the code for buttons
-
8/10/2019 Lab Manual3
101/118
101
)SEC CSE/IV DBMS LAB MANUAL
SOURCE CODE
Dim cn as New ADODB.Connection
Dim rs as New ADODB.Recordset
Dim rs1 as New ADODB.Recordset
Private sub Command1_Click()
Cn.Execute insert into payroll values(&Trim(Text1.Text)&, &Trim(Text2.Text)&,
&Trim(Text3.Text)&,&Trim(Text4.Text)&,&Trim(T ext5.Text)&,
&Trim(Text6.Text)&, &Trim(Text7.Text)&,
&Trim(Text8.Text)&,&Trim(Text9.Text)&,&Trim(Text10.Text)&,&Trim(Text1
1.Text)&,&Trim(Text12.Text)&,&Trim(Text13.Text)&,&Trim(Text14.Text)&)
Msgbox Inserted Successfully
End Sub
Private sub Command2_Click()
Cn.Execute update payroll set eno=&Trim(Text1.Text)&, ename=&Trim(Text2.Text)&
,dob=&Trim(Text3.Text)&,doj=&Trim(Text4.Tex t)&,dept=&Trim(Text5.Text)&
,design=&Trim(Text6.Text)&, bp=&Trim(Text7.Text)& ,
hra=&Trim(Text8.Text)&,da=&Trim(Text9.Text)&, allow=&Trim(Text10. Text)&
,loan=&Trim(Text11.Text)&,tax=&Trim(Text12.Text)&,ded=&Trim(Text13.Text
)&,np=&Trim(Text14.Text)& where eno=&Trim(Text1.Text)&
Msgbox Updated Successfully
End Sub
Private sub Command3_Click()
Cn.Execute delete from payroll where eno=&Trim(Text1.Text)&
Msgbox Deleted Successfully
End Sub
-
8/10/2019 Lab Manual3
102/118
102
SEC CSE/IV DBMS LAB MANUAL
Private sub Command4_Click()
Rs.MoveFirst
Setfields
End Sub
Private sub Command5_Click()
Rs.MovePrevious
Setfields
If rs.BOF then
Rs.MoveFirst
Setfields
End If
End Sub
Private sub Command6_Click()
Rs.MoveNext
Setfields
If rs.EOF then
Rs.MoveLast
Setfields
End If
End SubPrivate sub Command7_Click()
Rs.MoveLast
Setfields
-
8/10/2019 Lab Manual3
103/118
103
SEC CSE/IV DBMS LAB MANUAL
End SubPrivate sub Command7_Click() End
End Sub
Private sub Command9_Click() Dim f
F=InputBox(Enter employee number to search,search)
Text1.Text=f
Rs1.Open select * from payroll where eno=&Trim(Text1.Text)&
,cn,adOpenDynamic,adLockoptimistic
Setfields
Rs1.Close
End Sub
Private sub Form_Load()
Cn.Open Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\vbpgm\pay.mdb;Persist
Security Info=False
Rs.Open select * from payroll,cn,adOpenKeyset,adLockOptimistic End Sub
Private sub Text11_LostFocus()
If val(Trim(Text11.Text)=) Then
Text11.Text=Val(Text11.Text)End If
End Sub
Private sub Text12_LostFocus()
If val(Trim(Text12.Text)=) Then
Text12.Text=Val(Text12.Text)
-
8/10/2019 Lab Manual3
104/118
104
SEC CSE/IV DBMS LAB MANUAL
End If
End Sub
Private sub Text13_GotFocus() Text13.Text=Val(Text11.Text)+
Val(Text12.Text) End Sub
Private sub Text13_LostFocus() Text14.Text=Val(Text7.Text)+Val(Text10.Text)-
Val(Text13.Text) End Sub
Private sub Text7_LostFocus() If
Val(Text7.Text) 7000
-
8/10/2019 Lab Manual3
105/118
-
8/10/2019 Lab Manual3
106/118
106
SEC CSE/IV DBMS LAB MANUAL
VIVA QUESTION AND ANSWER
1. Define functional dependency.
A functional dependency is a constraint between two sets of attributes from the data base. A
functional dependency , denoted by X Y Between two sets of attributes X and Y that are
subsets of R specifies a constraint on the possible tuples that can form a relation instance r of
R.R={ A1,A2,,An}. The constraint states that, for any two tuples t1 and t2 in r such that
t1[X]=t2[X] , we must also have t1[Y] = t2[Y].We can also say that Y is functionally dependent
on X.
2. Define recoverable schedule.
Recoverable schedule is the one where for each pair of transactions Ti and Tj such that Tj reads a data
item previously written by Ti, the commit operation of Ti appears before the commit operation of Tj.
3. Define Query optimization.
The DBMS must devise an execution strategy for retrieving the result of the query from the database files.
Process of choosing a suitable execution strategy for processing a query is known as Query optimization.
POSSIBLE QUESTIONS
1. Create a project in VB for Payroll processing
2.Create a project in VB for company management.
3. Create a project in VB for industry management
-
8/10/2019 Lab Manual3
107/118
107
SEC CSE/IV DBMS LAB MANUAL
EX.NO:11(b)
DATE:
Database Design And Implementation(Mini Project)
Library Management System
Description:
To design a project (or) form using virtual basic as a front end tools and micro soft acess as aback.
Objective:
To design and implement a Library management using visual Basic
Requirements for execution:
S.No. Facilities
required
Quantity
1 System 1
2 OS Oracle 9i
Algorithm:
1. The table of the given database are identified along with their attributes and they are
created
2. Create database using access and insert some values into them
3. Create a new project in VB
4. Place the controls like Labels , text boxes in form
5. Set the caption property of label to the required field name
6. Delete the default values of the text box7. Double click the buttons and write the code for buttons
SOURCE CODE
BOOK DETAILS
Dim cn as New ADODB.Connection
-
8/10/2019 Lab Manual3
108/118
108
SEC CSE/IV DBMS LAB MANUAL
Dim rs as New ADODB.Recordset
Dim rs1 as New ADODB.Recordset
Private sub Command1_Click()
Cn.Execute insert into bdetails values(&Trim(Text1.Text)&,&Trim(Text2.Text)&,
&Trim(Text3.Text)&,&Tri m(Text4.Text)&)
MsgBox Inserted Successfully
End Sub
Private sub Command2_Click()
Cn.Execute update bdetails set bno=&Trim(Text1.text)&, bname=
&Trim(Text2. text)&, author=&Trim(Text3.text)&, nop=
&Trim(Text4.text)& where bno=&Trim(Text1.Text)&
MsgBox Updated Successfully
End Sub
Private sub Command3_Click()
Cn.Execute delete from bdetails where bno=&Trim(Text1.Text)&
MsgBox Deleted Successfully
End Sub
Private sub Command4_Click()
Dim f
F=InputBox(Enter the book number to find)
Text1.Text=f
Rs1.Open select * from bdetails where bno=&Trim(Text1.Text)&,
cn,adOpenDynamic,adLockoptimistic
-
8/10/2019 Lab Manual3
109/118
109
SEC CSE/IV DBMS LAB MANUAL
setfields
Rs1.Close
End Sub
Private sub Command5_Click()
Form1.Show
End Sub
Private sub Form_Load()
Cn.Open Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\vbpgm\library.mdb;Persist Security Info=False
Rs.Open select * from bdetails,cn,adOpenKeyset,adLockOptimistic
End SubPrivate sub setfields()
Text1=rs1(0)
Text2=rs1(1)
Text3=rs1(2)
Text4=rs1(3)
End Sub
STUDENT DETAILS
Dim cn as New ADODB.Connection
Dim rs as New ADODB.Recordset
Dim rs1 as New ADODB.Recordset
Private sub Command1_Click()
Cn.Execute insert into sdetails values(&Trim(Text1.Text)&,&Trim(Text2.Text)&,
-
8/10/2019 Lab Manual3
110/118
110
SEC CSE/IV DBMS LAB MANUAL
&Trim(Text3.Text)&,&Tri m(Text4.Text)&)
MsgBox Inserted Successfully
End Sub
Private sub Command2_Click()Cn.Execute update sdetails set stno=&Trim(Text1.text)&, stname=
&Trim(Text2.text)&, branch=&Trim(Text3.text)&,
year=&Trim(Text4.text)& where stno=&Trim(Text1.Text)&
MsgBox Updated Successfully
End Sub
Private sub Command3_Click()
Cn.Execute delete from sdetails where bno=&Trim(Text1.Text)&
MsgBox Deleted Successfully
End Sub
Private sub Command4_Click() Dim f
F=InputBox(Enter the student number to find)
Text1.Text=f
Rs1.Open select * from sdetails where stno=&Trim(Text1.Text)&
,cn,adOpenDynamic,adLockoptimistic
setfields
Rs1.Close End
Sub
Private sub Command5_Click()
Form2.Show
-
8/10/2019 Lab Manual3
111/118
-
8/10/2019 Lab Manual3
112/118
112
SEC CSE/IV DBMS LAB MANUAL
Private sub Command2_Click()
Cn.Execute update issdet set stno=&Trim(Text1.text)&, stname=&Trim(Text2
.text)& , branch= &Trim(Text3.text)& , year=&Trim(Text4.text)& ,bno=&Trim( Text5.text)&,
bname=&Trim(Text6.text)& , idate=&Trim(Text7.text)& ,rdate= &Trim(Text8.text)& , where
stno=&Trim(Text1.Text)&
MsgBox Updated Successfully
End SubPrivate sub Command3_Click()
Cn.Execute delete from issdet where stno=&Trim(Text1.Text)&
MsgBox Deleted Successfully
End Sub
Private sub Command4_Click() Dim f
F=InputBox(Enter the student number to find)
Text1.Text=f
Rs1.Open select * from issdet where stno=&Trim(Text1.Text)&,
cn,adOpenDynamic,adLockoptimistic
setfields
Rs1.Close End
Sub
Private sub Command5_Click()
Form3.Show
End Sub
Private sub Form_Load()
Cn.Open Provider=Microsoft.Jet.OLEDB.4.0;Data