Dbms lab manual

A

DBMS Lab Manual

DEPARTMENT OF INFORMATION TECHNOLOGY
LABORATORY MANUAL CUM OBSERVATION AND RECORD
CS8481 – DATABASE MANAGEMENT LABORATORY
(Regulation 2017)
Register Number : ___________________________________
Name of the Student : ___________________________________
2019 - 2020 EVEN
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
2 | P a g e K C E T
NAME :
BRANCH :
REGISTER NUMBER :
Bonafide record of work done in the CS8481 – DATABASE MANAGEMENT
LABORATORY of Kamaraj College of Engineering and Technology, Madurai, during the
academic year 2019 – 2020 EVEN.
Staff In – Charge Head of the Department
Submitted for the practical examination held on ___________________________ at Kamaraj
College of Engineering and Technology, Madurai.
Internal Examiner External Examiner
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
3 | P a g e K C E T
VISION OF THE INSTITUTE
To make this institute the unique of its kind in the field of Research and Development
activities in this part of world
MISSION OF THE INSTITUTE
To impart highly innovative and technical knowledge to the urban and unreachable rural
student folks through Total Quality Education
VISION OF THE DEPARTMENT
To make the department of Information Technology the unique of its kind in the field of
Research and Development activities in this part of world
MISSION OF THE DEPARTMENT
To impart highly innovative and technical knowledge in the field of Information Technology
to the urban and unreachable rural student folks through Total Quality Education
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
4 | P a g e K C E T
PROGRAM EDUCATION OBJECTIVE [PEO]
PEO 1: Graduates of the programme will exhibit expertise in technical knowledge by
applying distinctive skills in various fields of Information Technology
PEO 2: Graduates will become pioneers in the field of Information Technology by working
collaboratively and providing solutions to meet societal needs through persistent learning
PEO 3: Graduates will be able to adopt innovative practices and contribute towards research
and technological development in the field of Information Technology through Total Quality
Education
PROGRAM OUTCOMES (POs)
Engineering Graduates will be able to:
1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex
engineering problems.
2. Problem analysis: Identify, formulate, review research literature, and analyse
complex engineering problems reaching substantiated conclusions using first
principles of mathematics, natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering
problems and design system components or processes that meet the specified needs
with appropriate consideration for the public health and safety, and the cultural,
societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data,
and synthesis of the information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modelling to complex
engineering activities with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional
engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
5 | P a g e K C E T
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member
or leader in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with
the engineering community and with society at large, such as, being able to
comprehend and write effective reports and design documentation, make effective
presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a
member and leader in a team, to manage projects and in multidisciplinary
environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
PROGRAM SPECIFIC OUTCOMES (PSO)
Engineering Graduates will be able to:
PSO1 : Design an algorithm, process or component to address the real time needs in
the field of Information Technology through analytical skills
PSO2 : Ability to adopt the evolutionary changes in computing and pursue a career in
IT and IT - enabled industries
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
6 | P a g e K C E T
CS8481 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C
0 0 4 2
OBJECTIVES
1. To understand data definitions and data manipulation commands
2. To learn the use of nested and join queries
3. To understand functions, procedures and procedural extensions of data bases
4. To be familiar with the use of a front end tool
5. To understand design and implementation of typical database applications
LIST OF EXPERIMENTS
1. Data Definition Commands, Data Manipulation Commands for inserting, deleting,
updating and retrieving Tables and Transaction Control statements
2. Database Querying – Simple queries, Nested queries, Sub queries and Joins
3. Views, Sequences, Synonyms
4. Database Programming: Implicit and Explicit Cursors
5. Procedures and Functions
6. Triggers
7. Exception Handling
8. Database Design using ER modeling, normalization and Implementation for any
application
9. Database Connectivity with Front End Tools
10. Case Study using real life database applications
TOTAL: 60 PERIODS
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
7 | P a g e K C E T
COURSE OUTCOMES (COs)
Course
No.
Course Outcome
(Students will be able to)
Knowledge Level
R17C216.1
Demonstrate the use of relevant DDL, DML commands in database
creation and manipulation
K2 - Understanding
R17C216.2 Implement applications to test nested and join queries K3 - Apply
R17C216.3 Organize database using views, sequences, and synonyms K3 - Apply
R17C216.4
Implement functions, procedures, triggers and exceptions using
PL/SQL
K3 - Apply
R17C216.5 Construct database for real world scenario K3 - Apply
CO – PO MAPPING
Course
Outcomes
Program Outcomes
Program
Specific
Outcomes
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2
R17C216.1 M - - L L - - - L - - L L M
R17C216.2 M - - L L - - - L - - L L L
R17C216.3 L - - L L - - - L - - L M L
R17C216.4 M - - L L - - - L - - L M M
R17C216.5 H M M M L M - - M M - H H H
R17C216 M M M L L M - - L M - L M M
Correlation Levels : L:Slight M:Moderate H:Substantial
Target Value = ____________ % of Marks
Internal Assessment
S. No. Assessment Tool Percentage of Contribution
(%)
1 Laboratory Rubrics 75
2 Model Exam 25
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
8 | P a g e K C E T
RUBRICS FOR QUERY ASSESSMENT
Criteria 1 2 3 4 5
Drawing ER
Modelling
[20]
Identified and
represented the
entity and
relationship
correctly
[20]
Identified and
represented the entity
and relationship
correctly but has
flaws in attributes
[16]
Identified ER
correctly and
represented 75%
of it correctly
[12]
Identified ER
correctly and
represented
50% of it
correctly
[8]
Identified ER
correctly and
represented
25% of it
correctly
[4]
Query Logic
[10]
Explains the
basic concept
and query
correctly
[10]
Explains the logic
and basic concept
correctly but lacks in
oral presentation
[8]
Explains the
basic concept
correctly but
lacks in relating
with query
[6]
Explains the
basic concept
but fails to give
detail
description
[4]
Difficult in
explaining
the basic
concepts
[2]
Query Writing
[30]
All Queries are
correct
[30]
75% of the Queries
are correct
[22]
50% of the
Queries are
correct [18]
25% of the
Queries are
correct [10]
5% of the
queries are
correct[2]
Compilation
[20]
Completed on
day [20]
Completed in 2 days
delay
[15]
Completed in 4
days delay
[10]
Completed on
next lab
[5]
Failed to
completed
[0]
Record
Submission
[20]
Submitted on or
before next lab
[20]
Submitted with 2
days delay
[15]
Submitted with 4
days delay
[10]
Submitted on
next lab
[5]
Exceeds the
time of
Submission
[0]
RUBRICS FOR CASE STUDY ASSESSMENT
Criteria 1 2 3 4 5
Scope
[20]
Shows superior
knowledge of the
issues and key
problems
[20]
Shows adequate
knowledge of the
issues and key
problems
[15]
Shows some
understanding
of the issues and
key problems
[10]
Shows little
understanding
of the issues,
and key
problems
[5]
Shows no
understanding
of the issues
and key
problems
[0]
Originality
[30]
Demonstrates
critical thinking
about the topic
and develops
own
interpretations
[30]
Demonstrates
critical thinking
about the topic
and
interpretation can
be better
demonstrated
[23]
Case study
lacks some
critical thinking
about the topic
and
interpretations
[16]
Case study
lacks critical
thinking about
the topic and
lacks in
interpretations
[9]
No critical
thinking
about the
topic
[2]
Presentation
[30]
Professional, no
editing or
revision required
[30]
Professional,
Some light editing
may be useful
[23]
Revision
Suggested
[16]
Revision
Required
[16]
Lacks in
presentation
[2]
Conclusions and
Recommendations
[20]
Excellent
specification of
data or facts to
Specific data or
facts were
referred when
Specific data or
facts were
occasionally
Specific data
or facts were
not referred
Specific data
or facts
necessary to
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
9 | P a g e K C E T
support
conclusion.
[20]
necessary to
support
conclusions
[15]
referred when
necessary to
support
conclusions.
[10]
when
necessary to
support and
conclusions.
[5]
support
conclusions
was not
provided.
[0]
RUBRICS FOR EX 14 ASSESSMENT
Category 1 2 3 4
Objective
[20]
Shows superior
knowledge of the
issues and key
problems
[20]
Shows adequate
knowledge of the
issues and key
problems
[15]
Shows some
understanding of the
issues and key
problems
[10]
Shows little
understanding of the
issues, and key
problems
[5]
Drawing ER
Modelling
[20]
Identified and
represented the entity
and relationship
correctly
[20]
Identified and
represented the
entity and
relationship
correctly but has
flaws in attributes
[15]
Identified ER
correctly and
represented 75% of it
correctly
[10]
Identified ER
correctly and
represented 50% of it
correctly
[5]
Normalization
[30]
Database is
normalized
[30]
Database is 60%
normalized
[20]
Database is 30%
normalized
[10]
Database is not
normalized
[0]
Layout /Design
[20]
The pages are well
organized with tables.
Text spacing and
alignment make
reading easy. The
backgrounds enhance
the page.
[20]
The pages are eye-
catching and
attractive. Text is
easy to read. The
backgrounds are
subtle and
appropriate.
[15]
The pages appear
“busy” or “boring”.
Text may be difficult
to read. The
backgrounds are
somewhat
distracting.
[10]
The pages are
unattractive. Text is
difficult to read. The
backgrounds are
distracting.
[5]
Navigation
/Links
[20]
Links are created with
images and icons to
enhance the text links.
[20]
Links are consistent
and easy to find so
that the user can
easily navigate
back and forth
through pages.
[15]
The user may
become confused
when navigating
between pages.
Some links may not
work.
[10]
The user may become
lost or links may be
missing or not
working.
[5]
RUBRICS FOR EX 15 ASSESSMENT
Category 1 2 3 4
Contributions
[10]
Provides useful ideas
when doing group
work. A real leader
Usually provides
ideas in group
work. A strong
Sometimes provides
ideas in group work.
A satisfactory group
Rarely provides
ideas to the group.
May even refuse to
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
10 | P a g e K C E T
who contributes a lot
of effort.
[10]
member who tries
hard.
[7]
member who does
what is required.
[4]
participate.
[1]
Code Design
[30]
Written code that
satisfies the entire
logic
[30]
Code deigned with
some syntax errors
[20]
Code designed with
some logic mistakes
[10]
Code designed with
wrong logic
[0]
Database
Connectivity
[30]
Incorporated all
CURD operations
[30]
Incorporated all
CURD operations
but complicated
nested queries
[20]
Incorporated 50% of
CURD operations
[10]
Incorporated 20% of
CURD operations.
[0]
Conclusions and
Recommendations
[20]
Excellent
specification of data
or facts to support
conclusion.
[20]
Specific data or
facts were referred
when necessary to
support
conclusions
[15]
Specific data or
facts were
occasionally
referred when
necessary to support
conclusions.
[10]
Specific data or facts
were not referred
when necessary to
support and
conclusions.
[5]
Documentation
[10]
Well written,
organized, clear and
easy to follow
[10]
Adequately
written, organized,
clear and
reasonably easy to
follow
[7]
Adequately written
and organized but
unclear and hard to
follow
[4]
Poorly written and
organized, unclear,
hard to follow
[1]
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
11 | P a g e K C E T
CO ATTAINMENT - INTERNAL ASSESSMENT
Laboratory Mark
CO Number Mark Obtained
CO Attained?
[Y/N]
Signature
R17C216.1
R17C216.2
R17C216.3
R17C216.4
R17C216.5
Total Marks (100)
Model Exam
CO Number
Marks
Total Mark
CO Attained?
[Y/N]Allotted Obtained
Average
Internal Assessment = 75% of Laboratory Mark + 25% of Model Mark
=
Internal Assessment = _______________%
Note:
If CO Attainment,
Y = Laboratory Mark (%) >= Target Value (%)
N = Laboratory Mark (%) < Target Value (%)
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
12 | P a g e K C E T
INDEX
S. No. Date
CO
Number
Name of the Program
Page
Number
Mark
Obtained
[100]
Signature
CYCLE I
1 R17C216.1
Working with DDL, TCL and
DCL commands
2 R17C216.1
Working with DML
commands like insert, delete,
update and select.
3 R17C216.1
Working with SQL Clause
and SQL Aggregate
Functions.
4 R17C216.2
Working with Nested Queries
and Sub queries.
5 R17C216.2 Working with SQL Join.
CYCLE II
6 R17C216.3
Working with Views,
Synonyms, Sequence
7 R17C216.4 Working with Procedures
8 R17C216.4 Working with Cursors
9 R17C216.4 Working with Functions
10 R17C216.4 Working with Triggers
CYCLE III
11 R17C216.4
Working with PL/SQL
Exceptions commands
12 R17C216.5
Case study using real life data
base applications
13 R17C216.5 Study of PHP
14 R17C216.5
ER Modelling, Normalization
of Database and Font end
design for mini project
15 R17C216.5
Front end design,
Implementation and
connecting with Back end
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
13 | P a g e
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
1 | P a g e
Ex. No. 1
Date:
WORKING WITH DDL, TCL AND DCL COMMANDS Page No.
AIM:
To write simple queries using DDL, TCL and DCL commands.
QUERY BASE:
o Structured Query Language (SQL) as we all know is the database language by the use
of which we can perform certain operations on the existing database and also we can
use this language to create a database.
o SQL commands are mainly categorized into five categories as:
o DDL – Data Definition Language
o DQL – Data Query Language
o DML – Data Manipulation Language
o DCL – Data Control Language
o TCL – Transaction Control Language
o MySQL Data Types
o Numeric data types
 INT
 TINYINT
 SMALLINT
 MEDIUMINT
 BIGINT
 FLOAT(m,d)
 DOUBLE(m,d)
 DECIMAL(m,d)
o Date and Time data types
 DATE
 DATETIME
 TIMESTAMP(m)
 TIME
 YEAR[(2|4)]
o String data types
 CHAR(size)
 VARCHAR(size)
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
2 | P a g e
 TINYTEXT(size)
 TEXT(size)
 MEDIUMTEXT(size)
 LONGTEXT(size)
 BINARY(size)
 VARBINARY(size)
o Large Object data types
 TINYBLOB
 BLOB(size)
 MEDIUMBLOB
 LONGTEXT
o DDL Commands
o CREATING DATA BASE
Syntax:
mysql>create database databasename;
o To display the available databases
Syntax:
mysql>show databases;
o To use the database
Syntax:
mysql>use database;
o To drop the database
Syntax:
mysql>drop database databasename
o CREATING A TABLE
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
3 | P a g e
I. Creating a table without primary key and constraints:
Syntax:
mysql>create table tablename(column1 datatype1, column2 datatype2, column3
datatype3….etc.,);
II. To display the description about the table:
Syntax:
mysql >desc tablename;
III. Create table with primary key:
Way1:
Syntax:
mysql >create table tablename(column1 datatype1 primary key, column2
datatype2,…etc.,);
Way2:
Syntax:
mysql >create table tablename(column1 datatype1, column2 datatype2, column3
datatype3......primary key(columnname));
IV. Creating table using constraints:
Syntax:
mysql >create table tablename(column1 datatype1, column2 datatype2….
check(condition));
o ALTERING A TABLE
I. Adding primary key:
Syntax:
mysql >alter table tablename add primary key(columnname);
II. To remove a primary key:
Syntax:
mysql >alter table tablename drop primarykey;
III. Adding constraints:
Syntax:
mysql >alter table tablename add check(condition);
IV. Adding a new column:
Syntax:
mysql >alter table tablename add columnname datatype;
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
4 | P a g e
V. Modifying existing column:
Syntax:
mysql >alter table tablename modify columnname datatype;
VI. Removing a column.
Syntax:
mysql >alter table tablename drop column columnname ;
o DROP A TABLE
Syntax:
mysql >drop table tablename;
o TCL Commands
I. To undo the transaction:
Syntax:
mysql>rollback;
II. To save changes made by the transactions:
Syntax:
mysql>commit;
o DCL Commands
I. To gives user’s access privileges to database
Syntax:
Syntax:
mysql>grant <privilege list> on <relation name or view name> to <user/role list>;
II. To withdraw user’s access privileges
Syntax:
mysql>revoke <privilege list> on <relation name or view name> from <user name>;
DATABASE:
Use the table stud_profile only to perform operations
Columnname Datatype Size
rollno number 7
name varchar2 20
mobile_number number 10
dob date
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
5 | P a g e
ER DIAGRAM:
QUERY:
a. Create a table without primary key
b. Include the primary key
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
6 | P a g e
c. Drop the primary key
d. Remove the column mobile_number
e. Delete the table value
f. Truncate the table
g. Drop the table
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
7 | P a g e
h. Perform TCL commands
Rubrics Mark
ER Diagram [20]
Query Logic [10]
[Viva]
Query Writing [30]
Compilation [20]
Record Submission [20]
Total (100)
Signature
RESULT:
Thus, the simple queries are written and executed successfully.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
8 | P a g e
Ex. No. 2
Date:
WORKING WITH DML COMMANDS Page No.
AIM:
To write simple queries using DML commands.
QUERY BASE:
Insert a record into Table:
I. To insert the values to all the fields :
Syntax:
mysql>insert into tablename values(integervalue,’charactervalue’);
II. To insert the values to specific fields:
Syntax:
mysql>insert into tablename(columnname1,columnname2,..) values (integervalue,
’charactervalue’);
III. To insert the values during runtime:
Syntax:
SQL>insert into tablename values(&integer value ,’&character value’);
Display records from Table:
Syntax:
SQL> select columnname from tablename[where(condition)];
Delete rows from a table:
Syntax:
SQL> delete from tablename[where(condition)];
Update the Value of a Field:
Syntax:
SQL>update tablename set values/expression [where(condition)];
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
9 | P a g e
DATABASE:
Create a stable named Stud_Mark to perform DML operations
Columnname Datatype Size
rollno number 7
name number 5
sub_mark1 number 3
sub_mark2 number 3
sub_mark3 number 3
ER DIAGRAM:
QUERY:
i. Create a table with primary key and constraint for sub_mark1 and sub_mark2
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
10 | P a g e
ii. Include the constraint for sub_mark3
iii. Change the datatype of the field name as varchar2(20)
iv. Add a new column total
v. Insert 4 record into the table stud_mark [check for constraints]
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
11 | P a g e
vi. Display the inserted records
vii. Display the students failed in all the subjects
viii. Update the column total
ix. Insert 1 record except for the column total
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
12 | P a g e
x. Calculate the total for the newly inserted record
xi. Delete the record with rollno 20002
xii. Display all the students who have secured 80 mark in sub_mark1 and sub_mark2.
xiii. Display all the students who have secured 80 mark in sub_mark1 or sub_mark2.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
13 | P a g e
xiv. Display all the students who have secured marks above 80 in sub_mark1 and
sub_mark2.
xv. Display all the students who have secured marks between 60 to 80 in sub_mark3.
xvi. Display all the students who have secured marks (65,75,85) in sub_mark2.
xvii. Display the names of the student starting with 'a'.
xviii. Display the names of the student having 'h'
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
14 | P a g e
Rubrics Mark
ER Diagram [20]
Query Logic [10]
[Viva]
Query Writing [30]
Compilation [20]
Record Submission [20]
Total (100)
Signature
RESULT:
Thus, the simple queries are written and executed successfully.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
15 | P a g e
Practice:
a. Create a table client_master
i. client_master
Columnname Datatype Size
client_no varchar2 6
name varchar2 20
address varchar2 5
city varchar2 15
state varchar2 15
pincode number 6
b. Insert the following data into their respective tables:
client_no name address city state pincode
1000 Ram 45, Kamban street Virudhunagar Tamilnadu 626001
1001 Ramya
12/234, Anna
nagar
Madurai Tamilnadu 625001
1002 Sruthi 11, T. nagar Chennai Tamilnadu 600001
1003 Prasath
44, ranganathan
street
Chennai Tamilnadu 600001
1004 Ravi 7/90, Periyar street Madurai Tamilnadu 625001
1005 Rukmini 89, Nehru street Bombay Maharastra 400054
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
16 | P a g e
c. Answer the following question
i. Set the client_no as a primary key for client_master table
ii. Change the size of address in client_master table to varchar2(30)
iii. Include a new column as dob in the client_master table
iv. Update the new column in the client_master table
v. Find out the names and cities of all the clients
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
17 | P a g e
vi. List all the clients who are located in Chennai
vii. Display the information for client no 1002 and 1004
viii. Display the clients information whose is having the dob between
12.01.1980 and 12.01.1990
ix. Delete the record with client 1003 from the client master table
x. Remove the column pincode from the client_master table
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
18 | P a g e
Ex. No. 3
Date:
WORKING WITH SQL CLAUSE AND SQL AGGREGATE
FUNCTIONS
Page No.
AIM:
To write simple queries using aggregate functions and SQL clauses.
QUERY BASE:
SQL AGGREGATE FUNCTIONS
1. COUNT
 COUNT function is used to Count the number of rows in a database table. It can work
on both numeric and non-numeric data types.
 COUNT function uses the COUNT(*) that returns the count of all the rows in a
specified table. COUNT(*) considers duplicate and Null.
Syntax:
COUNT(*) or COUNT( [ALL|DISTINCT] expression )
Select count(argument) from tablename [where(condition)];
2. AVG
 The AVG function is used to calculate the average value of the numeric type. AVG
function returns the average of all non-Null values.
Syntax:
AVG() or AVG( [ALL|DISTINCT] expression )
Select avg(argument) from tablename [where(condition)];
3. SUM
 Sum function is used to calculate the sum of all selected columns. It works on
numeric fields only.
Syntax:
SUM() or SUM( [ALL|DISTINCT] expression )
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
19 | P a g e
Select sum(argument) from tablename [where(condition)];
4. MIN
 MIN function is used to find the minimum value of a certain column. This function
determines the smallest value of all selected values of a column.
Syntax:
MIN() or MIN( [ALL|DISTINCT] expression )
Select min(argument) from tablename [where(condition)];
5. MAX
 MAX function is used to find the maximum value of a certain column. This function
determines the largest value of all selected values of a column.
Syntax:
MAX() or MAX( [ALL|DISTINCT] expression )
Select max(argument) from tablename [where(condition)];
SQL CLAUSES
1. GROUP BY
 SQL GROUP BY statement is used to arrange identical data into groups. The GROUP
BY statement is used with the SQL SELECT statement.
 The GROUP BY statement follows the WHERE clause in a SELECT statement and
precedes the ORDER BY clause.
 The GROUP BY statement is used with aggregation function.
Syntax:
select column from table_name group by column
2. HAVING
 HAVING clause is used to specify a search condition for a group or an aggregate.
 Having is used in a GROUP BY clause. If you are not using GROUP BY clause then
you can use HAVING function like a WHERE clause.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
20 | P a g e
Syntax:
select column1, column2 from table_name group by column1, column2 having
conditions;
3. ORDER BY
 The ORDER BY clause sorts the result-set in ascending or descending order.
 It sorts the records in ascending order by default. DESC keyword is used to sort the
records in descending order.
Syntax:
select column1, column2 from table_name order by column1, column2... ASC|DESC;
where,
ASC: It is used to sort the result set in ascending order by expression.
DESC: It sorts the result set in descending order by expression.
DATABASE:
sailors_master
Columnname Datatype Size
sid number
sname varchar2 20
rating number
age number 2,1
ER DIAGRAM:
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
21 | P a g e
QUERY:
a. Create a table
b. Insert the following values into the table
sid sname rating age
22 Alice 7 45.0
29 Bob 1 33.0
31 Zoro 8 55.5
32 Ravi 8 25.5
58 Raj 10 35.0
64 Lubber 7 35.0
71 Horatio 10 16.0
74 Andy 9 35.0
85 Crist 3 25.5
95 Hary 3 63.5
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
22 | P a g e
c. Answer to the following query
i. Count the number of sailors
ii. Find the sum of rating in sailors
iii. Find the average age of all sailors
iv. Find the average age of sailors with a rating of 10
v. Find the age of youngest sailor
vi. Find the age of oldest sailor
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
23 | P a g e
vii. Find the age of youngest sailor whose rating level is 8
viii. Find the sum of age of sailors with rating greater than 5
ix. Display the names of sailor having ‘o’ as a second letter
x. Display the count of sailor having rating as 3
xi. Sort the sailors details based on rating
xii. Display the sailors name with high rating and age between 30 to 40
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
24 | P a g e
Rubrics Mark
ER Diagram [20]
Query Logic [10]
[Viva]
Query Writing [30]
Compilation [20]
Record Submission [20]
Total (100)
Signature
RESULT:
Thus, the simple queries using aggregated functions are written and executed
successfully.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
25 | P a g e
Ex. No. 4
Date:
WORKING WITH NESTED QUERIES AND SUB QUERIES Page No.
AIM:
To write nested and sub queries.
QUERY BASE:
Foreign key creation:
Syntax:
create table tablename(column1 datatype1,column2 datatype2,….child columnname
references parent tablename(parent columnname);
Nested Query:
Syntax:
select column_name from table_name where column_name expression operator
(select column_name from table_name where ... );
DATABASE:
department
Columnname Datatype Size
dno number Primary key
dname varchar2 30
location varchar2 20
numstaff number
employee
Columnname Datatype Size
eno number Primary key
ename varchar2 30
salary number
supno number
dno number Foreign key
works
Columnname Datatype Size
eno number Foreign key
pno number Foreign key
role varchar2 20
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
26 | P a g e
project
Columnname Datatype Size
pno number Primary key
pname varchar2 30
ptype varchar2 20
budget number
ER DIAGRAM:
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
27 | P a g e
QUERY:
a. Create the following table
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
28 | P a g e
b. Answer to the following queries
i. Get a list of project names with the employee numbers of the employees
working on them
ii. Get the names of employees in the ‘information’ department
iii. Get the names of all projects worked on by the employee. Get the name
during runtime.
iv. Get a list of employee names with their department names for employees
earning more than £25000
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
29 | P a g e
v. Get the employees with a lower than average salary
vi. Display the total number of projects worked by each employee
vii. How many employees are there in the ‘information’ department?
viii. Get a list of employee names for projects named ‘payroll’ or ‘database’.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
30 | P a g e
ix. Get the names of all employees with an above average salary.
x. Get the names and salaries of all employees in the ‘information’ department
with salaries above average for the ‘information’ department.
xi. Display the name of the employee who are working in more than one project
xii. Get the employee name and their department who is working with the
project worth between 30000 to 50000
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
31 | P a g e
xiii. Get the names and salaries of employees in the ‘information’ department
who has a higher salary than maximum salary in the ‘service’ department
xiv. Sort the projects based on ptype
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
32 | P a g e
Rubrics Mark
ER Diagram [20]
Query Logic [10]
[Viva]
Query Writing [30]
Compilation [20]
Record Submission [20]
Total (100)
Signature
RESULT:
Thus, the nested and sub queries are written and executed successfully.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
33 | P a g e
Ex. No. 5
Date:
WORKING WITH SQL JOIN Page No.
AIM:
To write queries using SQL Join.
QUERY BASE:
SQL JOIN
 JOIN means to combine something. In case of SQL, JOIN means "to combine two or
more tables".
Types of SQL JOIN
 INNER JOIN
 LEFT JOIN
 RIGHT JOIN
1. INNER JOIN
 In SQL, INNER JOIN selects records that have matching values in both tables as long
as the condition is satisfied. It returns the combination of all rows from both the tables
where the condition satisfies.
Syntax:
select columns from table1 inner join table2 on table1.column = table2.column;
2. LEFT OUTER JOIN
 The LEFT OUTER JOIN returns all rows from the left hand table specified in the ON
condition and only those rows from the other table where the join condition is
fulfilled.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
34 | P a g e
Syntax:
select columns from table1 left [outer] join table2 on table1.column = table2.column;
3. RIGHT OUTER JOIN
 The MySQL Right Outer Join returns all rows from the RIGHT-hand table specified
in the ON condition and only those rows from the other table where he join condition
is fulfilled.
Syntax:
select columns from table1 right [outer] join table2 on table1.column =
table2.column;
DATABASE:
department
Columnname Datatype Size
dno number Primary key
dname varchar2 30
location varchar2 20
doctor
Columnname Datatype Size
ssn number Primary key
docname varchar2 30
salary number
dno number Foreign key
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
35 | P a g e
takescare
Columnname Datatype Size
ssn number Foreign key
pid number Foreign key
patient
Columnname Datatype Size
pid number Primary key
pname varchar2 30
disease varchar2 20
date_of_admission Date
ward_no number
ER DIAGRAM:
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
36 | P a g e
QUERY:
a. Create the following table
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
37 | P a g e
i. Get the names of doctor in the ‘surgery’ department
ii. Get the names of all patients who take treatment under the doctor. Get the
name during runtime.
iii. Get a list of doctor names with their department names for doctor earning
more than Rs. 50000
iv. Get the doctor name with a lower than average salary
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
38 | P a g e
v. Display the total number of patients taking treatment under each doctor
vi. How many doctors are there in the ‘child specialist’ department?
vii. Get a list of doctor names who inspect ward number 2.
viii. Get the names of doctor who is having maximum salary.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
39 | P a g e
ix. Get the names and salaries of all doctor the ‘ortho’ department with salaries
above average for the ‘ortho' department.
x. Display the name of the doctor who are taking care of more than two patient.
xi. Get the doctor name and their department who is inspecting ward 1 and 4.
xii. Sort the doctor name based on docname
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
40 | P a g e
Rubrics Mark
ER Diagram [20]
Query Logic [10]
[Viva]
Query Writing [30]
Compilation [20]
Record Submission [20]
Total (100)
Signature
RESULT:
Thus, the queries using Joins are written and executed successfully.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
41 | P a g e
Ex. No. 6
Date:
WORKING WITH VIEWS, SYNONYMS, SEQUENCE Page No.
AIM:
To write queries using SQL views, synonyms and sequence.
QUERY BASE:
SQL VIEW
 View is a virtual table created by a query by joining one or more tables.
I. CREATING VIEW
 A VIEW is created by SELECT statements. SELECT statements are used to take data
from the source table to make a VIEW.
Syntax:
create [or replace] view view_name as select columns from tables [where conditions];
Parameters:
 OR REPLACE: It is optional. It is used when a VIEW already exist. If you do not
specify this clause and the VIEW already exists, the CREATE VIEW statement will
return an error.
 view_name: It specifies the name of the VIEW that you want to create in MySQL.
 WHERE conditions: It is also optional. It specifies the conditions that must be met for
the records to be included in the VIEW.
II. DISPLAY VIEW
Syntax:
SELECT * FROM VIEW_NAME;
III. UPDATE VIEW
 ALTER VIEW statement is used to modify or update the already created VIEW
without dropping it.
Syntax:
alter view view_name as select columns from table where conditions;
IV. DROP VIEW
Syntax:
drop view [if exists] view_name;
Parameters:
 view_name: It specifies the name of the VIEW that you want to drop.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
42 | P a g e
 IF EXISTS: It is optional. If you do not specify this clause and the VIEW doesn't
exist, the DROP VIEW statement will return an error.
SQL SEQUENCES
 A sequence is a set of integers 1, 2, 3, ... that are generated in order on a specific
demand.
 Sequences are frequently used in the databases because many applications require
each row in a table to contain a unique value and sequences provide an easy way to
generate them.
AUTO_INCREMENT Column
Syntax:
create table tableName (columnName datatype NOT NULL AUTO_INCREMENT =
value, ...);
DATABASE:
flight_header
Columnname Datatype Size
flight_id number Primary key
flight_name varchar2 25
ticket_header
Columnname Datatype Size
flight_id number Foreign key
ticket_no number Foreign key
origin varchar2 30
destination varchar2 30
no_of_adults number
no_of_children number
ticket_detail
Columnname Datatype Size
ticket_no number Primary key
name varchar2
gender varchar2
age number
fare number
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
43 | P a g e
ER DIAGRAM:
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
44 | P a g e
QUERY:
a. Create the following table (use sequence in flight_id in flight_header table)
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
45 | P a g e
i. Display the ticket number from both ticket_header and ticket_detail
ii. Display only the common flight_id that are present in flight_header and
ticket_header
iii. Display the flight that is not booked
iv. Create a view for the ticket_header table and display the number of details in
the view
v. Create a view to display the passengar detail of the flight having id 03
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
46 | P a g e
vi. Create a view for ticket_detail having flight id 01 and display the total amount
earned by flight 01 from view
vii. Create a view to display the name of the flight booked by the person alice
viii. Create a view to display the name of the person how is youngest in the
ticket_detail table
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
47 | P a g e
ix. Create a view to display the flight name starting with letter ‘k’
x. Create a view to display the total passenger and flight id for each flight
xi. Alter the view created in Q.x. to display the total fare collected in each flight
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
48 | P a g e
Rubrics Mark
ER Diagram [20]
Query Logic [10]
[Viva]
Query Writing [30]
Compilation [20]
Record Submission [20]
Total (100)
Signature
RESULT:
Thus, queries using views, synonyms and sequences are written and executed
successfully.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
49 | P a g e
Ex. No. 7
Date:
WORKING WITH PROCEDURES Page No.
AIM:
To write queries using PL/SQL procedures.
QUERY BASE:
 A procedure can return one or more than one value through parameters or may not
return at all. The procedure can be used in SQL queries.
I. CREATING PROCEDURE
Syntax
CREATE PROCEDURE procedure_name[ (parameter datatype [, parameter datatype]) ]
BEGIN
Declaration_section
Executable_section
END;
Parameter:
 procedure_name: name of the procedure.
 Parameter: number of parameters. It can be one or more than one.
 declaration_section: all variables are declared.
 executable_section: code for the function is written here.
II. DROP A PROCEDURE
 When a procedure is dropped, it is removed from the database.
Syntax:
Drop procedure[ IF EXISTS ] procedure_name;
III. CALL A PROCEDURE
mysql> call procedure_name;
DATABASE:
ticket_detail
Columnname Datatype Size
ticket_no number Primary key
name varchar2
gender varchar2
age number
fare number
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
50 | P a g e
ER DIAGRAM:
QUERY:
i. Write a procedure to display the female passenger list
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
51 | P a g e
ii. Write a procedure to display the passenger detail who are gents and having
the highest ticket fare
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
52 | P a g e
iii. Write a procedure to display the name of the passengers who have age
ranging from 20 to 45. Display in capital letter
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
53 | P a g e
iv. Write a procedure to display the name of the passenger who has the fare
above the average fare. Display in lower case
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
54 | P a g e
v. Write a procedure to display the passenger name who is having second letter
as ‘l’
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
55 | P a g e
Rubrics Mark
ER Diagram [20]
Query Logic [10]
[Viva]
Query Writing [30]
Compilation [20]
Record Submission [20]
Total (100)
Signature
RESULT:
Thus, queries using procedures are written and executed successfully.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
56 | P a g e
Ex. No. 8
Date:
WORKING WITH CURSORS Page No.
AIM:
To write queries using PL/SQL cursors.
QUERY BASE:
I. DECLARE CURSOR
 A cursor is a select statement, defined in the declaration section in MySQL.
Syntax
DECLARE cursor_name CURSOR FOR Select statement;
Parameter:
 cursor_name: name of the cursor
 select_statement: select query associated with the cursor
II. OPEN CURSOR
 After declaring the cursor the next step is to open the cursor using open statement.
Syntax
Open cursor_name;
Parameter:
 cursor_name: name of the cursor which is already declared.
III. FETCH CURSOR
 After declaring and opening the cursor, the next step is to fetch the cursor. It is used to
fetch the row or the column.
Syntax
FETCH [ NEXT [ FROM ] ] cursor_name INTO variable_list;
Parameter:
 cursor_name: name of the cursor
 variable_list: variables, comma separated, etc. is stored in a cursor for the result set
IV. Close Cursor
 The final step is to close the cursor.
Syntax
Close cursor_name;
Parameter:
 Cursor_name: name of the cursor
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
57 | P a g e
V. CALL THE CURSOR
Syntax
SET @name_list ="";
CALL list_name(@name_list);
SELECT @name_list;
DATABASE:
patient
Columnname Datatype Size
pid number Primary key
pname varchar2 30
disease varchar2 20
date_of_admission Date
ward_no number
ER DIAGRAM:
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
58 | P a g e
QUERY:
i. Write a procedure to display the patient information of the particular ward
no 2
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
59 | P a g e
ii. Write a procedure to display the name of the patient who has admitted
between 02.09.2010 to 25.10.2010. Display in capital letter
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
60 | P a g e
iii. Write a procedure to display the count of patients in each ward
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
61 | P a g e
iv. Write a procedure to display the patient name who is having last letter as ‘i’
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
62 | P a g e
v. Write a procedure to display the count patient with the particular disease
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
63 | P a g e
Rubrics Mark
ER Diagram [20]
Query Logic [10]
[Viva]
Query Writing [30]
Compilation [20]
Record Submission [20]
Total (100)
Signature
RESULT:
Thus, queries using cursors are written and executed successfully.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
64 | P a g e
Ex. No. 9
Date:
WORKING WITH FUNCTIONS Page No.
AIM:
To write queries using PL/SQL functions.
QUERY BASE:
I. CREATING A FUNCTION
 A function always returns a value using the return statement. The function can be
used in SQL queries.
Syntax
CREATE FUNCTION function_name [ (parameter datatype [, parameter datatype]) ]
RETURNS return_datatype
BEGIN
Declaration_section
Executable_section
END;
Parameter:
 Function_name: name of the function
 Parameter: number of parameter. It can be one or more than one.
 return_datatype: return value datatype of the function
 declaration_section: all variables are declared.
 executable_section: code for the function is written here.
II. DROP A FUNCTION
Syntax:
Drop function [ IF EXISTS ] function_name;
Parameter
 function_name: name of the function to be dropped.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
65 | P a g e
DATABASE:
sailors_master
Columnname Datatype Size
Sid number
Sname varchar2 20
Rating number
Age number 2,1
ER DIAGRAM:
QUERY:
i. Write a function to display the name of the sailor having particular sid. [get
the value of sid during run time]
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
66 | P a g e
ii. Write a function to display the total number of sailor in the database
iii. Write a function to display the average age of sailors with the rating 7
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
67 | P a g e
iv. Write a function to display the total number of sailors in the database
having the age as 35
v. Write a function to display the youngest sailor with rating 10
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
68 | P a g e
Rubrics Mark
ER Diagram [20]
Query Logic [10]
[Viva]
Query Writing [30]
Compilation [20]
Record Submission [20]
Total (100)
Signature
RESULT:
Thus, queries using functions are written and executed successfully.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
69 | P a g e
Ex. No. 10
Date:
WORKING WITH TRIGGERS Page No.
AIM:
To write queries using PL/SQL triggers.
QUERY BASE:
1. AFTER/BEFORE INSERT Trigger
 AFTER/BEFORE trigger means trigger will invoke after the record is inserted.
Syntax
CREATE TRIGGER trigger_name
AFTER/BEFORE INSERT
ON table_name FOR EACH ROW
BEGIN
--variable declarations
--trigger code
END;
Parameter:
 trigger_name: name of the trigger to be created.
 AFTER/BEFORE INSERT: It points the trigger after or before insert query is
executed
 table_name: name of the table in which a trigger is created.
2. AFTER/ BEFORE UPDATE Trigger
 AFTER/BEFORE UPDATE trigger means trigger will invoke after/before the record
is updated.
Syntax
CREATE TRIGGER trigger_name
AFTER/BEFORE UPDATE
ON table_name FOR EACH ROW
BEGIN
--variable declarations
--trigger code
END;
Parameter:
 trigger_name: name of the trigger to be created.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
70 | P a g e
 AFTER UPDATE: It points the trigger update query is executed.
 table_name: name of the table in which a trigger is created.
3. AFTER/BEFORE DELETE Trigger
 AFTER/BEFORE DELETE trigger means trigger will invoke after/before the record
is deleted.
Syntax
CREATE TRIGGER trigger_name
AFTER/BEFORE DELETE
ON table_name FOR EACH ROW
BEGIN
--variable declarations
--trigger code
END;
Parameter:
 trigger_name: name of the trigger to be created.
 AFTER/BEFORE DELETE: It points the trigger after/before delete query is executed.
 table_name: name of the table in which a trigger is created.
4. DROP TRIGGER
 When Trigger drops, then it is removed from the database.
Syntax
Drop Trigger[ IF EXISTS ] Trigger_name;
Parameter:
 Trigger_name: Name of the Trigger to be dropped
DATABASE:
Employee
Columnname Datatype Size
eno number Primary key
ename varchar2 30
designation varchar2 30
age number
address varchar2 30
salary number
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
71 | P a g e
ER DIAGRAM:
QUERY:
i. Write a trigger to display the salary difference between old salary and new salary.
[Show when insertion and updation]
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
72 | P a g e
ii. Write a trigger to prevent truncating a table.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
73 | P a g e
iii. Write a trigger to insert the record of deleted employee details with deleted date.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
74 | P a g e
iv. Write a trigger to insert old salary records of an employee once the salary is updated
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
75 | P a g e
v. Write a trigger to raise an application error if the detail of an employee with
designation as 'Manager' is deleted.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
76 | P a g e
Rubrics Mark
ER Diagram [20]
Query Logic [10]
[Viva]
Query Writing [30]
Compilation [20]
Record Submission [20]
Total (100)
Signature
RESULT:
Thus, queries using triggers are written and executed successfully.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
77 | P a g e
Ex. No. 11
Date:
WORKING WITH EXCEPTION Page No.
AIM:
To write queries using PL/SQL exception.
QUERY BASE:
 An error condition during a program execution is called an exception and the
mechanism for resolving such an exception is known as an exception handler.
Syntax
DECLARE
<declarations section>
BEGIN
<executable command(s)>
EXCEPTION
<exception handling goes here >
WHEN exception1 THEN
exception1-handling-statements
WHEN exception2 THEN
exception2-handling-statements
WHEN exception3 THEN
exception3-handling-statements
........
WHEN others THEN
exception3-handling-statements
END;
RAISING EXCEPTIONS
 Exceptions are raised by the database server automatically whenever there is any
internal database error, but exceptions can be raised explicitly by the programmer by
using the command RAISE.
DECLARE
exception_name EXCEPTION;
BEGIN
IF condition THEN
RAISE exception_name;
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
78 | P a g e
END IF;
EXCEPTION
WHEN exception_name THEN
statement;
END;
CREATING USER DEFINED EXCEPTION
Syntax
DECLARE
my-exception EXCEPTION;
DATABASE:
book
Columnname Datatype Size
Bid Number
Bname Varchar2 30
Author Varchar2 30
Edition Number
Price Number
ER DIAGRAM:
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
79 | P a g e
QUERY:
i. Write an exception code if the price of the code does not satisfy the constraint
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
80 | P a g e
ii. Write an exception code to raise exception when trying to access an empty book table
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
81 | P a g e
iii. Write an exception code to raise an exception when no such book is found
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
82 | P a g e
iv. Write a user defined exception code if the book has second edition
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
83 | P a g e
Rubrics Mark
ER Diagram [20]
Query Logic [10]
[Viva]
Query Writing [30]
Compilation [20]
Record Submission [20]
Total (100)
Signature
RESULT:
Thus, queries using exception are written and executed successfully.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
84 | P a g e
Ex. No. 12
Date:
CASE STUDY USING REAL LIFE DATA BASE
APPLICATIONS
Page No.
AIM:
To perform case study for any real life database applications.
CASE STUDY:
PROBLEM STATEMENT:
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
85 | P a g e
SOLUTION:
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
86 | P a g e
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
87 | P a g e
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
88 | P a g e
CONCLUSION:
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
89 | P a g e
Rubrics Mark
Scope [20]
Originality [30]
Presentation [30]
Conclusions and Recommendations
[20]
Total (100)
Signature
RESULT:
Thus, case study for real life database application is done.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
90 | P a g e
Ex. No. 13
Date:
STUDY OF PHP Page No.
AIM:
To study PHP for front end design and back end connectivity.
BASICS:
 PHP is a server side scripting language.
 PHP is an interpreted language, i.e. there is no need for compilation.
 PHP is an object-oriented language.
 PHP is an open-source scripting language.
 PHP is simple and easy to learn language.
Syntax:
<?php
//your code here
?>
DATA TYPES
 PHP data types are used to hold different types of data or values. PHP supports 8
primitive data types that can be categorized further in 3 types:
o Scalar Types
o Compound Types
o Special Types
PHP Data Types: Scalar Types
There are 4 scalar data types in PHP.
o boolean
o integer
o float
o string
PHP Data Types: Compound Types
There are 2 compound data types in PHP.
o array
o object
PHP Data Types: Special Types
There are 2 special data types in PHP.
o resource
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
91 | P a g e
o NULL
PHP OPERATORS
 Arithmetic Operators
 Comparison Operators
 Bitwise Operators
 Logical Operators
 String Operators
 Incrementing/Decrementing Operators
 Array Operators
 Type Operators
 Execution Operators
 Error Control Operators
 Assignment Operators
We can also categorize operators on behalf of operands. They can be categorized in 3 forms:
 Unary Operators: works on single operands such as ++, -- etc.
 Binary Operators: works on two operands such as binary +, -, *, / etc.
 Ternary Operators: works on three operands such as "?:".
PHP CONTROL STATEMENTS
 Branching
o if else
o switch
 Looping
o for
o while
o do..while
 Unconditional Statement
o Break
PHP ARRAYS
Syntax
$variable = array(values separated in commas);
PHP WITH MYSQL
PHP mysqli_connect()
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
92 | P a g e
o PHP mysqli_connect() function is used to connect with MySQL database. It returns
resource if connection is established or null.
Syntax
resource mysqli_connect (server, username, password)
PHP mysqli_close()
o PHP mysqli_close() function is used to disconnect with MySQL database. It returns
true if connection is closed or false.
Syntax
bool mysqli_close(resource $resource_link)
PHP MySQLi Create Database Example
<?php
$host = 'localhost:3306';
$user = '';
$pass = '';
$conn = mysqli_connect($host, $user, $pass);
if(! $conn )
{
die('Could not connect: ' . mysqli_connect_error());
}
echo 'Connected successfully<br/>';
$sql = 'CREATE Database mydb';
if(mysqli_query( $conn,$sql)){
echo "Database mydb created successfully.";
}else{
echo "Sorry, database creation failed ".mysqli_error($conn);
}
mysqli_close($conn);
?>
MySQLi Create Table Example
<?php
$host = 'localhost:3306';
$user = '';
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
93 | P a g e
$pass = '';
$dbname = 'test';
$conn = mysqli_connect($host, $user, $pass,$dbname);
if(!$conn){
die('Could not connect: '.mysqli_connect_error());
}
echo 'Connected successfully<br/>';
$sql = "create table emp5(id INT AUTO_INCREMENT,name VARCHAR(20) NOT NULL,
emp_salary INT NOT NULL,primary key (id))";
if(mysqli_query($conn, $sql)){
echo "Table emp5 created successfully";
}else{
echo "Could not create table: ". mysqli_error($conn);
}
mysqli_close($conn);
?>
PHP MySQLi Insert Record Example
Example
<?php
$host = 'localhost:3306';
$user = '';
$pass = '';
$dbname = 'test';
$conn = mysqli_connect($host, $user, $pass,$dbname);
if(!$conn){
die('Could not connect: '.mysqli_connect_error());
}
echo 'Connected successfully<br/>';
$sql = 'INSERT INTO emp4(name,salary) VALUES ("sonoo", 9000)';
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
94 | P a g e
if(mysqli_query($conn, $sql)){
echo "Record inserted successfully";
}else{
echo "Could not insert record: ". mysqli_error($conn);
}
mysqli_close($conn);
?>
PHP MySQLi Update Record Example
<?php
$host = 'localhost:3306';
$user = '';
$pass = '';
$dbname = 'test';
$conn = mysqli_connect($host, $user, $pass,$dbname);
if(!$conn){
die('Could not connect: '.mysqli_connect_error());
}
echo 'Connected successfully<br/>';
$id=2;
$name="Rahul";
$salary=80000;
$sql = "update emp4 set name="$name", salary=$salary where id=$id";
if(mysqli_query($conn, $sql)){
echo "Record updated successfully";
}else{
echo "Could not update record: ". mysqli_error($conn);
}
mysqli_close($conn);
?>
PHP MySQLi Delete Record Example
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
95 | P a g e
Example
<?php
$host = 'localhost:3306';
$user = '';
$pass = '';
$dbname = 'test';
$conn = mysqli_connect($host, $user, $pass,$dbname);
if(!$conn){
die('Could not connect: '.mysqli_connect_error());
}
echo 'Connected successfully<br/>';
$id=2;
$sql = "delete from emp4 where id=$id";
if(mysqli_query($conn, $sql)){
echo "Record deleted successfully";
}else{
echo "Could not deleted record: ". mysqli_error($conn);
}
mysqli_close($conn);
?>
PHP MySQLi Select Query Example
<?php
$host = 'localhost:3306';
$user = '';
$pass = '';
$dbname = 'test';
$conn = mysqli_connect($host, $user, $pass,$dbname);
if(!$conn){
die('Could not connect: '.mysqli_connect_error());
}
echo 'Connected successfully<br/>';
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
96 | P a g e
$sql = 'SELECT * FROM emp4';
$retval=mysqli_query($conn, $sql);
if(mysqli_num_rows($retval) > 0){
while($row = mysqli_fetch_assoc($retval)){
echo "EMP ID :{$row['id']} <br> ".
"EMP NAME : {$row['name']} <br> ".
"EMP SALARY : {$row['salary']} <br> ".
"--------------------------------<br>";
} //end of while
}else{
echo "0 results";
}
mysqli_close($conn);
?>
PHP MySQLi Order by Example
Example
<?php
$host = 'localhost:3306';
$user = '';
$pass = '';
$dbname = 'test';
$conn = mysqli_connect($host, $user, $pass,$dbname);
if(!$conn){
die('Could not connect: '.mysqli_connect_error());
}
echo 'Connected successfully<br/>';
$sql = 'SELECT * FROM emp4 order by name';
$retval=mysqli_query($conn, $sql);
if(mysqli_num_rows($retval) > 0){
while($row = mysqli_fetch_assoc($retval)){
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
97 | P a g e
echo "EMP ID :{$row['id']} <br> ".
"EMP NAME : {$row['name']} <br> ".
"EMP SALARY : {$row['salary']} <br> ".
"--------------------------------<br>";
} //end of while
}else{
echo "0 results";
}
mysqli_close($conn);
?>
RESULT:
Thus, basics for designing and database connectivity using PHP is done
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
98 | P a g e
Ex. No. 14
Date:
ER MODELLING, NORMALIZATION OF DATABASE
AND FONT END DESIGN FOR MINI PROJECT
Page No.
MINI PROJECT TITLE:
OBJECTIVE:
ROUGH DRAFT DATABASE:
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
99 | P a g e
ER MODEL
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
100 | P a g e
NORMALIZATION
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
101 | P a g e
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
102 | P a g e
TABLE DESIGN
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
103 | P a g e
FRONT END DESIGN
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
104 | P a g e
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
105 | P a g e
Rubrics Mark
Objective [20]
Drawing ER Modeling [20]
Normalization [30]
Layout /Design [20]
Navigation /Links [20]
Total [100]
Signature
RESULT:
Thus, case study for real life database application is done.
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
106 | P a g e
Ex. No. 15
Date:
FRONT END DESIGN, IMPLEMENTATION AND
CONNECTING WITH BACK END
Page No.
CONNECTION STRING
SCREEN SHOTS
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
107 | P a g e
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
108 | P a g e
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
109 | P a g e
CONCLUSION:
FUTURE ENHANCEMENT:
CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN)
110 | P a g e
Rubrics Mark
Contributions [10]
Code Design [30]
Database Connectivity [30]
Conclusions and Recommendations
[20]
Documentation [10]
Total [100]
Signature

Recommandé

data abstraction ,encapsulation,A.D.T par
data abstraction ,encapsulation,A.D.Tdata abstraction ,encapsulation,A.D.T
data abstraction ,encapsulation,A.D.Tkapil10197
3.3K vues24 diapositives
2- THE CHANGING NATURE OF SOFTWARE.pdf par
2- THE CHANGING NATURE OF SOFTWARE.pdf2- THE CHANGING NATURE OF SOFTWARE.pdf
2- THE CHANGING NATURE OF SOFTWARE.pdfbcanawakadalcollege
4.9K vues8 diapositives
Recognition-of-tokens par
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokensDattatray Gandhmal
33.5K vues25 diapositives
Software Engineering by Pankaj Jalote par
Software Engineering by Pankaj JaloteSoftware Engineering by Pankaj Jalote
Software Engineering by Pankaj JaloteGolda Margret Sheeba J
6K vues44 diapositives
Daa notes 1 par
Daa notes 1Daa notes 1
Daa notes 1smruti sarangi
8.7K vues153 diapositives
Non Deterministic and Deterministic Problems par
Non Deterministic and Deterministic Problems Non Deterministic and Deterministic Problems
Non Deterministic and Deterministic Problems Scandala Tamang
855 vues11 diapositives

Contenu connexe

Tendances

System testing par
System testingSystem testing
System testingKinnudj Amee
2.2K vues5 diapositives
Developing an ASP.NET Web Application par
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web ApplicationRishi Kothari
28.4K vues43 diapositives
Uml in software engineering par
Uml in software engineeringUml in software engineering
Uml in software engineeringMubashir Jutt
2.6K vues15 diapositives
Software estimation par
Software estimationSoftware estimation
Software estimationMd Shakir
23.5K vues40 diapositives
Architectural styles and patterns par
Architectural styles and patternsArchitectural styles and patterns
Architectural styles and patternsHimanshu
27.9K vues12 diapositives
Introduction to Software Engineering par
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software EngineeringSaqib Raza
38.2K vues42 diapositives

Tendances(20)

Developing an ASP.NET Web Application par Rishi Kothari
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web Application
Rishi Kothari28.4K vues
Uml in software engineering par Mubashir Jutt
Uml in software engineeringUml in software engineering
Uml in software engineering
Mubashir Jutt2.6K vues
Software estimation par Md Shakir
Software estimationSoftware estimation
Software estimation
Md Shakir23.5K vues
Architectural styles and patterns par Himanshu
Architectural styles and patternsArchitectural styles and patterns
Architectural styles and patterns
Himanshu 27.9K vues
Introduction to Software Engineering par Saqib Raza
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software Engineering
Saqib Raza38.2K vues
Algorithms Lecture 1: Introduction to Algorithms par Benha University
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Benha University3.3K vues
Software quality assurance par Aman Adhikari
Software quality assuranceSoftware quality assurance
Software quality assurance
Aman Adhikari51.3K vues
Our presentation on algorithm design par Nahid Hasan
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm design
Nahid Hasan22K vues
Software project management par R A Akerkar
Software project managementSoftware project management
Software project management
R A Akerkar69.3K vues
Introduction to oops concepts par Nilesh Dalvi
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
Nilesh Dalvi71.9K vues
Fundamentals of data structures ellis horowitz & sartaj sahni par Hitesh Wagle
Fundamentals of data structures   ellis horowitz & sartaj sahniFundamentals of data structures   ellis horowitz & sartaj sahni
Fundamentals of data structures ellis horowitz & sartaj sahni
Hitesh Wagle60.5K vues
Regular expressions-Theory of computation par Bipul Roy Bpl
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
Bipul Roy Bpl5.9K vues
Data structures and algorithms par Julie Iskander
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
Julie Iskander13.2K vues

Similaire à Dbms lab manual

Cs8581 networks lab manual 2017 par
Cs8581 networks lab manual   2017Cs8581 networks lab manual   2017
Cs8581 networks lab manual 2017Kayathri Devi D
2.6K vues79 diapositives
Ade manual with co po-18scheme par
Ade manual with co po-18schemeAde manual with co po-18scheme
Ade manual with co po-18schemeAMC Engineering College
633 vues49 diapositives
Hdllab1 par
Hdllab1Hdllab1
Hdllab1Gopinath.B.L Naidu
576 vues78 diapositives
SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdf par
SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdfSDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdf
SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdfpriyanshuurkade
6 vues40 diapositives
Dsp lab manual par
Dsp lab manualDsp lab manual
Dsp lab manualamanabr
114 vues131 diapositives
SE LAB MANUAL (R16).pdf par
SE LAB MANUAL (R16).pdfSE LAB MANUAL (R16).pdf
SE LAB MANUAL (R16).pdfSRPatel10
52 vues63 diapositives

Similaire à Dbms lab manual(20)

SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdf par priyanshuurkade
SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdfSDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdf
SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdf
Dsp lab manual par amanabr
Dsp lab manualDsp lab manual
Dsp lab manual
amanabr114 vues
SE LAB MANUAL (R16).pdf par SRPatel10
SE LAB MANUAL (R16).pdfSE LAB MANUAL (R16).pdf
SE LAB MANUAL (R16).pdf
SRPatel1052 vues
CS8662 Mobile Application Development Lab Manual par pkaviya
CS8662 Mobile Application Development Lab ManualCS8662 Mobile Application Development Lab Manual
CS8662 Mobile Application Development Lab Manual
pkaviya3.5K vues
Report[Batch-08].pdf par 052Sugashk
Report[Batch-08].pdfReport[Batch-08].pdf
Report[Batch-08].pdf
052Sugashk56 vues
FdSc Mechanical Engineering par bwcelearning
FdSc Mechanical EngineeringFdSc Mechanical Engineering
FdSc Mechanical Engineering
bwcelearning345 vues
Materials Engineering Digital Notes.pdf par SaiM624606
Materials Engineering Digital Notes.pdfMaterials Engineering Digital Notes.pdf
Materials Engineering Digital Notes.pdf
SaiM62460678 vues
B tech cse syllabus - MITAOE par MITAcademy1
B tech cse syllabus - MITAOEB tech cse syllabus - MITAOE
B tech cse syllabus - MITAOE
MITAcademy189 vues
CS8383 Object Oriented Programming Laboratory Manual par Muthu Vinayagam
CS8383 Object Oriented Programming Laboratory ManualCS8383 Object Oriented Programming Laboratory Manual
CS8383 Object Oriented Programming Laboratory Manual
Muthu Vinayagam8.6K vues
IRJET- Teaching Learning Practices for Metrology & Quality Control Subject in... par IRJET Journal
IRJET- Teaching Learning Practices for Metrology & Quality Control Subject in...IRJET- Teaching Learning Practices for Metrology & Quality Control Subject in...
IRJET- Teaching Learning Practices for Metrology & Quality Control Subject in...
IRJET Journal32 vues
SE_Computer_Engg__2019_course_28_06_2021 (6).pdf par tomlee12821
SE_Computer_Engg__2019_course_28_06_2021 (6).pdfSE_Computer_Engg__2019_course_28_06_2021 (6).pdf
SE_Computer_Engg__2019_course_28_06_2021 (6).pdf
tomlee1282183 vues

Plus de ArthyR3

ANGULARJS.pdf par
ANGULARJS.pdfANGULARJS.pdf
ANGULARJS.pdfArthyR3
2 vues10 diapositives
JQUERY.pdf par
JQUERY.pdfJQUERY.pdf
JQUERY.pdfArthyR3
6 vues22 diapositives
Qb it1301 par
Qb   it1301Qb   it1301
Qb it1301ArthyR3
125 vues84 diapositives
CNS - Unit v par
CNS - Unit vCNS - Unit v
CNS - Unit vArthyR3
107 vues48 diapositives
Cs8792 cns - unit v par
Cs8792   cns - unit vCs8792   cns - unit v
Cs8792 cns - unit vArthyR3
439 vues89 diapositives
Cs8792 cns - unit iv par
Cs8792   cns - unit ivCs8792   cns - unit iv
Cs8792 cns - unit ivArthyR3
118 vues153 diapositives

Plus de ArthyR3(20)

ANGULARJS.pdf par ArthyR3
ANGULARJS.pdfANGULARJS.pdf
ANGULARJS.pdf
ArthyR32 vues
Qb it1301 par ArthyR3
Qb   it1301Qb   it1301
Qb it1301
ArthyR3125 vues
CNS - Unit v par ArthyR3
CNS - Unit vCNS - Unit v
CNS - Unit v
ArthyR3107 vues
Cs8792 cns - unit v par ArthyR3
Cs8792   cns - unit vCs8792   cns - unit v
Cs8792 cns - unit v
ArthyR3439 vues
Cs8792 cns - unit iv par ArthyR3
Cs8792   cns - unit ivCs8792   cns - unit iv
Cs8792 cns - unit iv
ArthyR3118 vues
Cs8792 cns - unit iv par ArthyR3
Cs8792   cns - unit ivCs8792   cns - unit iv
Cs8792 cns - unit iv
ArthyR3568 vues
Cs8792 cns - unit i par ArthyR3
Cs8792   cns - unit iCs8792   cns - unit i
Cs8792 cns - unit i
ArthyR3892 vues
Java quick reference par ArthyR3
Java quick referenceJava quick reference
Java quick reference
ArthyR3171 vues
Cs8792 cns - Public key cryptosystem (Unit III) par ArthyR3
Cs8792   cns - Public key cryptosystem (Unit III)Cs8792   cns - Public key cryptosystem (Unit III)
Cs8792 cns - Public key cryptosystem (Unit III)
ArthyR3818 vues
Cryptography Workbook par ArthyR3
Cryptography WorkbookCryptography Workbook
Cryptography Workbook
ArthyR3420 vues
Cs6701 cryptography and network security par ArthyR3
Cs6701 cryptography and network securityCs6701 cryptography and network security
Cs6701 cryptography and network security
ArthyR3343 vues
Compiler question bank par ArthyR3
Compiler question bankCompiler question bank
Compiler question bank
ArthyR3421 vues
Compiler gate question key par ArthyR3
Compiler gate question keyCompiler gate question key
Compiler gate question key
ArthyR3139 vues
Java conceptual learning material par ArthyR3
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
ArthyR3284 vues
Cyber forensics question bank par ArthyR3
Cyber forensics   question bankCyber forensics   question bank
Cyber forensics question bank
ArthyR3268 vues
Compiler worksheet par ArthyR3
Compiler worksheetCompiler worksheet
Compiler worksheet
ArthyR3139 vues
Google classroom par ArthyR3
Google classroomGoogle classroom
Google classroom
ArthyR3163 vues

Dernier

Quality Manual Chaity Group.pdf par
Quality Manual Chaity Group.pdfQuality Manual Chaity Group.pdf
Quality Manual Chaity Group.pdfMizan Rahman
5 vues61 diapositives
Effect of deep chemical mixing columns on properties of surrounding soft clay... par
Effect of deep chemical mixing columns on properties of surrounding soft clay...Effect of deep chemical mixing columns on properties of surrounding soft clay...
Effect of deep chemical mixing columns on properties of surrounding soft clay...AltinKaradagli
6 vues10 diapositives
NEW SUPPLIERS SUPPLIES (copie).pdf par
NEW SUPPLIERS SUPPLIES (copie).pdfNEW SUPPLIERS SUPPLIES (copie).pdf
NEW SUPPLIERS SUPPLIES (copie).pdfgeorgesradjou
15 vues30 diapositives
DESIGN OF SPRINGS-UNIT4.pptx par
DESIGN OF SPRINGS-UNIT4.pptxDESIGN OF SPRINGS-UNIT4.pptx
DESIGN OF SPRINGS-UNIT4.pptxgopinathcreddy
19 vues47 diapositives
Object Oriented Programming with JAVA par
Object Oriented Programming with JAVAObject Oriented Programming with JAVA
Object Oriented Programming with JAVADemian Antony D'Mello
119 vues28 diapositives
Digital Watermarking Of Audio Signals.pptx par
Digital Watermarking Of Audio Signals.pptxDigital Watermarking Of Audio Signals.pptx
Digital Watermarking Of Audio Signals.pptxAyushJaiswal781174
11 vues25 diapositives

Dernier(20)

Quality Manual Chaity Group.pdf par Mizan Rahman
Quality Manual Chaity Group.pdfQuality Manual Chaity Group.pdf
Quality Manual Chaity Group.pdf
Mizan Rahman5 vues
Effect of deep chemical mixing columns on properties of surrounding soft clay... par AltinKaradagli
Effect of deep chemical mixing columns on properties of surrounding soft clay...Effect of deep chemical mixing columns on properties of surrounding soft clay...
Effect of deep chemical mixing columns on properties of surrounding soft clay...
NEW SUPPLIERS SUPPLIES (copie).pdf par georgesradjou
NEW SUPPLIERS SUPPLIES (copie).pdfNEW SUPPLIERS SUPPLIES (copie).pdf
NEW SUPPLIERS SUPPLIES (copie).pdf
georgesradjou15 vues
zincalume water storage tank design.pdf par 3D LABS
zincalume water storage tank design.pdfzincalume water storage tank design.pdf
zincalume water storage tank design.pdf
3D LABS5 vues
Taking out the Trash (And the Recyclables]: RFID and the Handling of Municipa... par ijseajournal
Taking out the Trash (And the Recyclables]: RFID and the Handling of Municipa...Taking out the Trash (And the Recyclables]: RFID and the Handling of Municipa...
Taking out the Trash (And the Recyclables]: RFID and the Handling of Municipa...
ijseajournal5 vues
An approach of ontology and knowledge base for railway maintenance par IJECEIAES
An approach of ontology and knowledge base for railway maintenanceAn approach of ontology and knowledge base for railway maintenance
An approach of ontology and knowledge base for railway maintenance
IJECEIAES12 vues
Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ... par AltinKaradagli
Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ...Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ...
Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ...
Machine learning in drug supply chain management during disease outbreaks: a ... par IJECEIAES
Machine learning in drug supply chain management during disease outbreaks: a ...Machine learning in drug supply chain management during disease outbreaks: a ...
Machine learning in drug supply chain management during disease outbreaks: a ...
IJECEIAES12 vues
SUMIT SQL PROJECT SUPERSTORE 1.pptx par Sumit Jadhav
SUMIT SQL PROJECT SUPERSTORE 1.pptxSUMIT SQL PROJECT SUPERSTORE 1.pptx
SUMIT SQL PROJECT SUPERSTORE 1.pptx
Sumit Jadhav 12 vues
A multi-microcontroller-based hardware for deploying Tiny machine learning mo... par IJECEIAES
A multi-microcontroller-based hardware for deploying Tiny machine learning mo...A multi-microcontroller-based hardware for deploying Tiny machine learning mo...
A multi-microcontroller-based hardware for deploying Tiny machine learning mo...
IJECEIAES13 vues
MSA Website Slideshow (16).pdf par msaucla
MSA Website Slideshow (16).pdfMSA Website Slideshow (16).pdf
MSA Website Slideshow (16).pdf
msaucla64 vues
Design of machine elements-UNIT 3.pptx par gopinathcreddy
Design of machine elements-UNIT 3.pptxDesign of machine elements-UNIT 3.pptx
Design of machine elements-UNIT 3.pptx
gopinathcreddy32 vues

Dbms lab manual

  • 1. DEPARTMENT OF INFORMATION TECHNOLOGY LABORATORY MANUAL CUM OBSERVATION AND RECORD CS8481 – DATABASE MANAGEMENT LABORATORY (Regulation 2017) Register Number : ___________________________________ Name of the Student : ___________________________________ 2019 - 2020 EVEN
  • 2. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 2 | P a g e K C E T NAME : BRANCH : REGISTER NUMBER : Bonafide record of work done in the CS8481 – DATABASE MANAGEMENT LABORATORY of Kamaraj College of Engineering and Technology, Madurai, during the academic year 2019 – 2020 EVEN. Staff In – Charge Head of the Department Submitted for the practical examination held on ___________________________ at Kamaraj College of Engineering and Technology, Madurai. Internal Examiner External Examiner
  • 3. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 3 | P a g e K C E T VISION OF THE INSTITUTE To make this institute the unique of its kind in the field of Research and Development activities in this part of world MISSION OF THE INSTITUTE To impart highly innovative and technical knowledge to the urban and unreachable rural student folks through Total Quality Education VISION OF THE DEPARTMENT To make the department of Information Technology the unique of its kind in the field of Research and Development activities in this part of world MISSION OF THE DEPARTMENT To impart highly innovative and technical knowledge in the field of Information Technology to the urban and unreachable rural student folks through Total Quality Education
  • 4. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 4 | P a g e K C E T PROGRAM EDUCATION OBJECTIVE [PEO] PEO 1: Graduates of the programme will exhibit expertise in technical knowledge by applying distinctive skills in various fields of Information Technology PEO 2: Graduates will become pioneers in the field of Information Technology by working collaboratively and providing solutions to meet societal needs through persistent learning PEO 3: Graduates will be able to adopt innovative practices and contribute towards research and technological development in the field of Information Technology through Total Quality Education PROGRAM OUTCOMES (POs) Engineering Graduates will be able to: 1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an engineering specialization to the solution of complex engineering problems. 2. Problem analysis: Identify, formulate, review research literature, and analyse complex engineering problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences. 3. Design/development of solutions: Design solutions for complex engineering problems and design system components or processes that meet the specified needs with appropriate consideration for the public health and safety, and the cultural, societal, and environmental considerations. 4. Conduct investigations of complex problems: Use research-based knowledge and research methods including design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid conclusions. 5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and IT tools including prediction and modelling to complex engineering activities with an understanding of the limitations. 6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice. 7. Environment and sustainability: Understand the impact of the professional engineering solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable development.
  • 5. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 5 | P a g e K C E T 8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering practice. 9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams, and in multidisciplinary settings. 10. Communication: Communicate effectively on complex engineering activities with the engineering community and with society at large, such as, being able to comprehend and write effective reports and design documentation, make effective presentations, and give and receive clear instructions. 11. Project management and finance: Demonstrate knowledge and understanding of the engineering and management principles and apply these to one’s own work, as a member and leader in a team, to manage projects and in multidisciplinary environments. 12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent and life-long learning in the broadest context of technological change. PROGRAM SPECIFIC OUTCOMES (PSO) Engineering Graduates will be able to: PSO1 : Design an algorithm, process or component to address the real time needs in the field of Information Technology through analytical skills PSO2 : Ability to adopt the evolutionary changes in computing and pursue a career in IT and IT - enabled industries
  • 6. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 6 | P a g e K C E T CS8481 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C 0 0 4 2 OBJECTIVES 1. To understand data definitions and data manipulation commands 2. To learn the use of nested and join queries 3. To understand functions, procedures and procedural extensions of data bases 4. To be familiar with the use of a front end tool 5. To understand design and implementation of typical database applications LIST OF EXPERIMENTS 1. Data Definition Commands, Data Manipulation Commands for inserting, deleting, updating and retrieving Tables and Transaction Control statements 2. Database Querying – Simple queries, Nested queries, Sub queries and Joins 3. Views, Sequences, Synonyms 4. Database Programming: Implicit and Explicit Cursors 5. Procedures and Functions 6. Triggers 7. Exception Handling 8. Database Design using ER modeling, normalization and Implementation for any application 9. Database Connectivity with Front End Tools 10. Case Study using real life database applications TOTAL: 60 PERIODS
  • 7. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 7 | P a g e K C E T COURSE OUTCOMES (COs) Course No. Course Outcome (Students will be able to) Knowledge Level R17C216.1 Demonstrate the use of relevant DDL, DML commands in database creation and manipulation K2 - Understanding R17C216.2 Implement applications to test nested and join queries K3 - Apply R17C216.3 Organize database using views, sequences, and synonyms K3 - Apply R17C216.4 Implement functions, procedures, triggers and exceptions using PL/SQL K3 - Apply R17C216.5 Construct database for real world scenario K3 - Apply CO – PO MAPPING Course Outcomes Program Outcomes Program Specific Outcomes PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2 R17C216.1 M - - L L - - - L - - L L M R17C216.2 M - - L L - - - L - - L L L R17C216.3 L - - L L - - - L - - L M L R17C216.4 M - - L L - - - L - - L M M R17C216.5 H M M M L M - - M M - H H H R17C216 M M M L L M - - L M - L M M Correlation Levels : L:Slight M:Moderate H:Substantial Target Value = ____________ % of Marks Internal Assessment S. No. Assessment Tool Percentage of Contribution (%) 1 Laboratory Rubrics 75 2 Model Exam 25
  • 8. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 8 | P a g e K C E T RUBRICS FOR QUERY ASSESSMENT Criteria 1 2 3 4 5 Drawing ER Modelling [20] Identified and represented the entity and relationship correctly [20] Identified and represented the entity and relationship correctly but has flaws in attributes [16] Identified ER correctly and represented 75% of it correctly [12] Identified ER correctly and represented 50% of it correctly [8] Identified ER correctly and represented 25% of it correctly [4] Query Logic [10] Explains the basic concept and query correctly [10] Explains the logic and basic concept correctly but lacks in oral presentation [8] Explains the basic concept correctly but lacks in relating with query [6] Explains the basic concept but fails to give detail description [4] Difficult in explaining the basic concepts [2] Query Writing [30] All Queries are correct [30] 75% of the Queries are correct [22] 50% of the Queries are correct [18] 25% of the Queries are correct [10] 5% of the queries are correct[2] Compilation [20] Completed on day [20] Completed in 2 days delay [15] Completed in 4 days delay [10] Completed on next lab [5] Failed to completed [0] Record Submission [20] Submitted on or before next lab [20] Submitted with 2 days delay [15] Submitted with 4 days delay [10] Submitted on next lab [5] Exceeds the time of Submission [0] RUBRICS FOR CASE STUDY ASSESSMENT Criteria 1 2 3 4 5 Scope [20] Shows superior knowledge of the issues and key problems [20] Shows adequate knowledge of the issues and key problems [15] Shows some understanding of the issues and key problems [10] Shows little understanding of the issues, and key problems [5] Shows no understanding of the issues and key problems [0] Originality [30] Demonstrates critical thinking about the topic and develops own interpretations [30] Demonstrates critical thinking about the topic and interpretation can be better demonstrated [23] Case study lacks some critical thinking about the topic and interpretations [16] Case study lacks critical thinking about the topic and lacks in interpretations [9] No critical thinking about the topic [2] Presentation [30] Professional, no editing or revision required [30] Professional, Some light editing may be useful [23] Revision Suggested [16] Revision Required [16] Lacks in presentation [2] Conclusions and Recommendations [20] Excellent specification of data or facts to Specific data or facts were referred when Specific data or facts were occasionally Specific data or facts were not referred Specific data or facts necessary to
  • 9. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 9 | P a g e K C E T support conclusion. [20] necessary to support conclusions [15] referred when necessary to support conclusions. [10] when necessary to support and conclusions. [5] support conclusions was not provided. [0] RUBRICS FOR EX 14 ASSESSMENT Category 1 2 3 4 Objective [20] Shows superior knowledge of the issues and key problems [20] Shows adequate knowledge of the issues and key problems [15] Shows some understanding of the issues and key problems [10] Shows little understanding of the issues, and key problems [5] Drawing ER Modelling [20] Identified and represented the entity and relationship correctly [20] Identified and represented the entity and relationship correctly but has flaws in attributes [15] Identified ER correctly and represented 75% of it correctly [10] Identified ER correctly and represented 50% of it correctly [5] Normalization [30] Database is normalized [30] Database is 60% normalized [20] Database is 30% normalized [10] Database is not normalized [0] Layout /Design [20] The pages are well organized with tables. Text spacing and alignment make reading easy. The backgrounds enhance the page. [20] The pages are eye- catching and attractive. Text is easy to read. The backgrounds are subtle and appropriate. [15] The pages appear “busy” or “boring”. Text may be difficult to read. The backgrounds are somewhat distracting. [10] The pages are unattractive. Text is difficult to read. The backgrounds are distracting. [5] Navigation /Links [20] Links are created with images and icons to enhance the text links. [20] Links are consistent and easy to find so that the user can easily navigate back and forth through pages. [15] The user may become confused when navigating between pages. Some links may not work. [10] The user may become lost or links may be missing or not working. [5] RUBRICS FOR EX 15 ASSESSMENT Category 1 2 3 4 Contributions [10] Provides useful ideas when doing group work. A real leader Usually provides ideas in group work. A strong Sometimes provides ideas in group work. A satisfactory group Rarely provides ideas to the group. May even refuse to
  • 10. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 10 | P a g e K C E T who contributes a lot of effort. [10] member who tries hard. [7] member who does what is required. [4] participate. [1] Code Design [30] Written code that satisfies the entire logic [30] Code deigned with some syntax errors [20] Code designed with some logic mistakes [10] Code designed with wrong logic [0] Database Connectivity [30] Incorporated all CURD operations [30] Incorporated all CURD operations but complicated nested queries [20] Incorporated 50% of CURD operations [10] Incorporated 20% of CURD operations. [0] Conclusions and Recommendations [20] Excellent specification of data or facts to support conclusion. [20] Specific data or facts were referred when necessary to support conclusions [15] Specific data or facts were occasionally referred when necessary to support conclusions. [10] Specific data or facts were not referred when necessary to support and conclusions. [5] Documentation [10] Well written, organized, clear and easy to follow [10] Adequately written, organized, clear and reasonably easy to follow [7] Adequately written and organized but unclear and hard to follow [4] Poorly written and organized, unclear, hard to follow [1]
  • 11. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 11 | P a g e K C E T CO ATTAINMENT - INTERNAL ASSESSMENT Laboratory Mark CO Number Mark Obtained CO Attained? [Y/N] Signature R17C216.1 R17C216.2 R17C216.3 R17C216.4 R17C216.5 Total Marks (100) Model Exam CO Number Marks Total Mark CO Attained? [Y/N]Allotted Obtained Average Internal Assessment = 75% of Laboratory Mark + 25% of Model Mark = Internal Assessment = _______________% Note: If CO Attainment, Y = Laboratory Mark (%) >= Target Value (%) N = Laboratory Mark (%) < Target Value (%)
  • 12. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 12 | P a g e K C E T INDEX S. No. Date CO Number Name of the Program Page Number Mark Obtained [100] Signature CYCLE I 1 R17C216.1 Working with DDL, TCL and DCL commands 2 R17C216.1 Working with DML commands like insert, delete, update and select. 3 R17C216.1 Working with SQL Clause and SQL Aggregate Functions. 4 R17C216.2 Working with Nested Queries and Sub queries. 5 R17C216.2 Working with SQL Join. CYCLE II 6 R17C216.3 Working with Views, Synonyms, Sequence 7 R17C216.4 Working with Procedures 8 R17C216.4 Working with Cursors 9 R17C216.4 Working with Functions 10 R17C216.4 Working with Triggers CYCLE III 11 R17C216.4 Working with PL/SQL Exceptions commands 12 R17C216.5 Case study using real life data base applications 13 R17C216.5 Study of PHP 14 R17C216.5 ER Modelling, Normalization of Database and Font end design for mini project 15 R17C216.5 Front end design, Implementation and connecting with Back end
  • 13. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 13 | P a g e
  • 14. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 1 | P a g e Ex. No. 1 Date: WORKING WITH DDL, TCL AND DCL COMMANDS Page No. AIM: To write simple queries using DDL, TCL and DCL commands. QUERY BASE: o Structured Query Language (SQL) as we all know is the database language by the use of which we can perform certain operations on the existing database and also we can use this language to create a database. o SQL commands are mainly categorized into five categories as: o DDL – Data Definition Language o DQL – Data Query Language o DML – Data Manipulation Language o DCL – Data Control Language o TCL – Transaction Control Language o MySQL Data Types o Numeric data types  INT  TINYINT  SMALLINT  MEDIUMINT  BIGINT  FLOAT(m,d)  DOUBLE(m,d)  DECIMAL(m,d) o Date and Time data types  DATE  DATETIME  TIMESTAMP(m)  TIME  YEAR[(2|4)] o String data types  CHAR(size)  VARCHAR(size)
  • 15. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 2 | P a g e  TINYTEXT(size)  TEXT(size)  MEDIUMTEXT(size)  LONGTEXT(size)  BINARY(size)  VARBINARY(size) o Large Object data types  TINYBLOB  BLOB(size)  MEDIUMBLOB  LONGTEXT o DDL Commands o CREATING DATA BASE Syntax: mysql>create database databasename; o To display the available databases Syntax: mysql>show databases; o To use the database Syntax: mysql>use database; o To drop the database Syntax: mysql>drop database databasename o CREATING A TABLE
  • 16. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 3 | P a g e I. Creating a table without primary key and constraints: Syntax: mysql>create table tablename(column1 datatype1, column2 datatype2, column3 datatype3….etc.,); II. To display the description about the table: Syntax: mysql >desc tablename; III. Create table with primary key: Way1: Syntax: mysql >create table tablename(column1 datatype1 primary key, column2 datatype2,…etc.,); Way2: Syntax: mysql >create table tablename(column1 datatype1, column2 datatype2, column3 datatype3......primary key(columnname)); IV. Creating table using constraints: Syntax: mysql >create table tablename(column1 datatype1, column2 datatype2…. check(condition)); o ALTERING A TABLE I. Adding primary key: Syntax: mysql >alter table tablename add primary key(columnname); II. To remove a primary key: Syntax: mysql >alter table tablename drop primarykey; III. Adding constraints: Syntax: mysql >alter table tablename add check(condition); IV. Adding a new column: Syntax: mysql >alter table tablename add columnname datatype;
  • 17. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 4 | P a g e V. Modifying existing column: Syntax: mysql >alter table tablename modify columnname datatype; VI. Removing a column. Syntax: mysql >alter table tablename drop column columnname ; o DROP A TABLE Syntax: mysql >drop table tablename; o TCL Commands I. To undo the transaction: Syntax: mysql>rollback; II. To save changes made by the transactions: Syntax: mysql>commit; o DCL Commands I. To gives user’s access privileges to database Syntax: Syntax: mysql>grant <privilege list> on <relation name or view name> to <user/role list>; II. To withdraw user’s access privileges Syntax: mysql>revoke <privilege list> on <relation name or view name> from <user name>; DATABASE: Use the table stud_profile only to perform operations Columnname Datatype Size rollno number 7 name varchar2 20 mobile_number number 10 dob date
  • 18. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 5 | P a g e ER DIAGRAM: QUERY: a. Create a table without primary key b. Include the primary key
  • 19. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 6 | P a g e c. Drop the primary key d. Remove the column mobile_number e. Delete the table value f. Truncate the table g. Drop the table
  • 20. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 7 | P a g e h. Perform TCL commands Rubrics Mark ER Diagram [20] Query Logic [10] [Viva] Query Writing [30] Compilation [20] Record Submission [20] Total (100) Signature RESULT: Thus, the simple queries are written and executed successfully.
  • 21. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 8 | P a g e Ex. No. 2 Date: WORKING WITH DML COMMANDS Page No. AIM: To write simple queries using DML commands. QUERY BASE: Insert a record into Table: I. To insert the values to all the fields : Syntax: mysql>insert into tablename values(integervalue,’charactervalue’); II. To insert the values to specific fields: Syntax: mysql>insert into tablename(columnname1,columnname2,..) values (integervalue, ’charactervalue’); III. To insert the values during runtime: Syntax: SQL>insert into tablename values(&integer value ,’&character value’); Display records from Table: Syntax: SQL> select columnname from tablename[where(condition)]; Delete rows from a table: Syntax: SQL> delete from tablename[where(condition)]; Update the Value of a Field: Syntax: SQL>update tablename set values/expression [where(condition)];
  • 22. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 9 | P a g e DATABASE: Create a stable named Stud_Mark to perform DML operations Columnname Datatype Size rollno number 7 name number 5 sub_mark1 number 3 sub_mark2 number 3 sub_mark3 number 3 ER DIAGRAM: QUERY: i. Create a table with primary key and constraint for sub_mark1 and sub_mark2
  • 23. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 10 | P a g e ii. Include the constraint for sub_mark3 iii. Change the datatype of the field name as varchar2(20) iv. Add a new column total v. Insert 4 record into the table stud_mark [check for constraints]
  • 24. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 11 | P a g e vi. Display the inserted records vii. Display the students failed in all the subjects viii. Update the column total ix. Insert 1 record except for the column total
  • 25. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 12 | P a g e x. Calculate the total for the newly inserted record xi. Delete the record with rollno 20002 xii. Display all the students who have secured 80 mark in sub_mark1 and sub_mark2. xiii. Display all the students who have secured 80 mark in sub_mark1 or sub_mark2.
  • 26. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 13 | P a g e xiv. Display all the students who have secured marks above 80 in sub_mark1 and sub_mark2. xv. Display all the students who have secured marks between 60 to 80 in sub_mark3. xvi. Display all the students who have secured marks (65,75,85) in sub_mark2. xvii. Display the names of the student starting with 'a'. xviii. Display the names of the student having 'h'
  • 27. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 14 | P a g e Rubrics Mark ER Diagram [20] Query Logic [10] [Viva] Query Writing [30] Compilation [20] Record Submission [20] Total (100) Signature RESULT: Thus, the simple queries are written and executed successfully.
  • 28. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 15 | P a g e Practice: a. Create a table client_master i. client_master Columnname Datatype Size client_no varchar2 6 name varchar2 20 address varchar2 5 city varchar2 15 state varchar2 15 pincode number 6 b. Insert the following data into their respective tables: client_no name address city state pincode 1000 Ram 45, Kamban street Virudhunagar Tamilnadu 626001 1001 Ramya 12/234, Anna nagar Madurai Tamilnadu 625001 1002 Sruthi 11, T. nagar Chennai Tamilnadu 600001 1003 Prasath 44, ranganathan street Chennai Tamilnadu 600001 1004 Ravi 7/90, Periyar street Madurai Tamilnadu 625001 1005 Rukmini 89, Nehru street Bombay Maharastra 400054
  • 29. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 16 | P a g e c. Answer the following question i. Set the client_no as a primary key for client_master table ii. Change the size of address in client_master table to varchar2(30) iii. Include a new column as dob in the client_master table iv. Update the new column in the client_master table v. Find out the names and cities of all the clients
  • 30. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 17 | P a g e vi. List all the clients who are located in Chennai vii. Display the information for client no 1002 and 1004 viii. Display the clients information whose is having the dob between 12.01.1980 and 12.01.1990 ix. Delete the record with client 1003 from the client master table x. Remove the column pincode from the client_master table
  • 31. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 18 | P a g e Ex. No. 3 Date: WORKING WITH SQL CLAUSE AND SQL AGGREGATE FUNCTIONS Page No. AIM: To write simple queries using aggregate functions and SQL clauses. QUERY BASE: SQL AGGREGATE FUNCTIONS 1. COUNT  COUNT function is used to Count the number of rows in a database table. It can work on both numeric and non-numeric data types.  COUNT function uses the COUNT(*) that returns the count of all the rows in a specified table. COUNT(*) considers duplicate and Null. Syntax: COUNT(*) or COUNT( [ALL|DISTINCT] expression ) Select count(argument) from tablename [where(condition)]; 2. AVG  The AVG function is used to calculate the average value of the numeric type. AVG function returns the average of all non-Null values. Syntax: AVG() or AVG( [ALL|DISTINCT] expression ) Select avg(argument) from tablename [where(condition)]; 3. SUM  Sum function is used to calculate the sum of all selected columns. It works on numeric fields only. Syntax: SUM() or SUM( [ALL|DISTINCT] expression )
  • 32. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 19 | P a g e Select sum(argument) from tablename [where(condition)]; 4. MIN  MIN function is used to find the minimum value of a certain column. This function determines the smallest value of all selected values of a column. Syntax: MIN() or MIN( [ALL|DISTINCT] expression ) Select min(argument) from tablename [where(condition)]; 5. MAX  MAX function is used to find the maximum value of a certain column. This function determines the largest value of all selected values of a column. Syntax: MAX() or MAX( [ALL|DISTINCT] expression ) Select max(argument) from tablename [where(condition)]; SQL CLAUSES 1. GROUP BY  SQL GROUP BY statement is used to arrange identical data into groups. The GROUP BY statement is used with the SQL SELECT statement.  The GROUP BY statement follows the WHERE clause in a SELECT statement and precedes the ORDER BY clause.  The GROUP BY statement is used with aggregation function. Syntax: select column from table_name group by column 2. HAVING  HAVING clause is used to specify a search condition for a group or an aggregate.  Having is used in a GROUP BY clause. If you are not using GROUP BY clause then you can use HAVING function like a WHERE clause.
  • 33. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 20 | P a g e Syntax: select column1, column2 from table_name group by column1, column2 having conditions; 3. ORDER BY  The ORDER BY clause sorts the result-set in ascending or descending order.  It sorts the records in ascending order by default. DESC keyword is used to sort the records in descending order. Syntax: select column1, column2 from table_name order by column1, column2... ASC|DESC; where, ASC: It is used to sort the result set in ascending order by expression. DESC: It sorts the result set in descending order by expression. DATABASE: sailors_master Columnname Datatype Size sid number sname varchar2 20 rating number age number 2,1 ER DIAGRAM:
  • 34. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 21 | P a g e QUERY: a. Create a table b. Insert the following values into the table sid sname rating age 22 Alice 7 45.0 29 Bob 1 33.0 31 Zoro 8 55.5 32 Ravi 8 25.5 58 Raj 10 35.0 64 Lubber 7 35.0 71 Horatio 10 16.0 74 Andy 9 35.0 85 Crist 3 25.5 95 Hary 3 63.5
  • 35. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 22 | P a g e c. Answer to the following query i. Count the number of sailors ii. Find the sum of rating in sailors iii. Find the average age of all sailors iv. Find the average age of sailors with a rating of 10 v. Find the age of youngest sailor vi. Find the age of oldest sailor
  • 36. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 23 | P a g e vii. Find the age of youngest sailor whose rating level is 8 viii. Find the sum of age of sailors with rating greater than 5 ix. Display the names of sailor having ‘o’ as a second letter x. Display the count of sailor having rating as 3 xi. Sort the sailors details based on rating xii. Display the sailors name with high rating and age between 30 to 40
  • 37. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 24 | P a g e Rubrics Mark ER Diagram [20] Query Logic [10] [Viva] Query Writing [30] Compilation [20] Record Submission [20] Total (100) Signature RESULT: Thus, the simple queries using aggregated functions are written and executed successfully.
  • 38. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 25 | P a g e Ex. No. 4 Date: WORKING WITH NESTED QUERIES AND SUB QUERIES Page No. AIM: To write nested and sub queries. QUERY BASE: Foreign key creation: Syntax: create table tablename(column1 datatype1,column2 datatype2,….child columnname references parent tablename(parent columnname); Nested Query: Syntax: select column_name from table_name where column_name expression operator (select column_name from table_name where ... ); DATABASE: department Columnname Datatype Size dno number Primary key dname varchar2 30 location varchar2 20 numstaff number employee Columnname Datatype Size eno number Primary key ename varchar2 30 salary number supno number dno number Foreign key works Columnname Datatype Size eno number Foreign key pno number Foreign key role varchar2 20
  • 39. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 26 | P a g e project Columnname Datatype Size pno number Primary key pname varchar2 30 ptype varchar2 20 budget number ER DIAGRAM:
  • 40. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 27 | P a g e QUERY: a. Create the following table
  • 41. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 28 | P a g e b. Answer to the following queries i. Get a list of project names with the employee numbers of the employees working on them ii. Get the names of employees in the ‘information’ department iii. Get the names of all projects worked on by the employee. Get the name during runtime. iv. Get a list of employee names with their department names for employees earning more than £25000
  • 42. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 29 | P a g e v. Get the employees with a lower than average salary vi. Display the total number of projects worked by each employee vii. How many employees are there in the ‘information’ department? viii. Get a list of employee names for projects named ‘payroll’ or ‘database’.
  • 43. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 30 | P a g e ix. Get the names of all employees with an above average salary. x. Get the names and salaries of all employees in the ‘information’ department with salaries above average for the ‘information’ department. xi. Display the name of the employee who are working in more than one project xii. Get the employee name and their department who is working with the project worth between 30000 to 50000
  • 44. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 31 | P a g e xiii. Get the names and salaries of employees in the ‘information’ department who has a higher salary than maximum salary in the ‘service’ department xiv. Sort the projects based on ptype
  • 45. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 32 | P a g e Rubrics Mark ER Diagram [20] Query Logic [10] [Viva] Query Writing [30] Compilation [20] Record Submission [20] Total (100) Signature RESULT: Thus, the nested and sub queries are written and executed successfully.
  • 46. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 33 | P a g e Ex. No. 5 Date: WORKING WITH SQL JOIN Page No. AIM: To write queries using SQL Join. QUERY BASE: SQL JOIN  JOIN means to combine something. In case of SQL, JOIN means "to combine two or more tables". Types of SQL JOIN  INNER JOIN  LEFT JOIN  RIGHT JOIN 1. INNER JOIN  In SQL, INNER JOIN selects records that have matching values in both tables as long as the condition is satisfied. It returns the combination of all rows from both the tables where the condition satisfies. Syntax: select columns from table1 inner join table2 on table1.column = table2.column; 2. LEFT OUTER JOIN  The LEFT OUTER JOIN returns all rows from the left hand table specified in the ON condition and only those rows from the other table where the join condition is fulfilled.
  • 47. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 34 | P a g e Syntax: select columns from table1 left [outer] join table2 on table1.column = table2.column; 3. RIGHT OUTER JOIN  The MySQL Right Outer Join returns all rows from the RIGHT-hand table specified in the ON condition and only those rows from the other table where he join condition is fulfilled. Syntax: select columns from table1 right [outer] join table2 on table1.column = table2.column; DATABASE: department Columnname Datatype Size dno number Primary key dname varchar2 30 location varchar2 20 doctor Columnname Datatype Size ssn number Primary key docname varchar2 30 salary number dno number Foreign key
  • 48. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 35 | P a g e takescare Columnname Datatype Size ssn number Foreign key pid number Foreign key patient Columnname Datatype Size pid number Primary key pname varchar2 30 disease varchar2 20 date_of_admission Date ward_no number ER DIAGRAM:
  • 49. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 36 | P a g e QUERY: a. Create the following table
  • 50. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 37 | P a g e i. Get the names of doctor in the ‘surgery’ department ii. Get the names of all patients who take treatment under the doctor. Get the name during runtime. iii. Get a list of doctor names with their department names for doctor earning more than Rs. 50000 iv. Get the doctor name with a lower than average salary
  • 51. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 38 | P a g e v. Display the total number of patients taking treatment under each doctor vi. How many doctors are there in the ‘child specialist’ department? vii. Get a list of doctor names who inspect ward number 2. viii. Get the names of doctor who is having maximum salary.
  • 52. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 39 | P a g e ix. Get the names and salaries of all doctor the ‘ortho’ department with salaries above average for the ‘ortho' department. x. Display the name of the doctor who are taking care of more than two patient. xi. Get the doctor name and their department who is inspecting ward 1 and 4. xii. Sort the doctor name based on docname
  • 53. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 40 | P a g e Rubrics Mark ER Diagram [20] Query Logic [10] [Viva] Query Writing [30] Compilation [20] Record Submission [20] Total (100) Signature RESULT: Thus, the queries using Joins are written and executed successfully.
  • 54. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 41 | P a g e Ex. No. 6 Date: WORKING WITH VIEWS, SYNONYMS, SEQUENCE Page No. AIM: To write queries using SQL views, synonyms and sequence. QUERY BASE: SQL VIEW  View is a virtual table created by a query by joining one or more tables. I. CREATING VIEW  A VIEW is created by SELECT statements. SELECT statements are used to take data from the source table to make a VIEW. Syntax: create [or replace] view view_name as select columns from tables [where conditions]; Parameters:  OR REPLACE: It is optional. It is used when a VIEW already exist. If you do not specify this clause and the VIEW already exists, the CREATE VIEW statement will return an error.  view_name: It specifies the name of the VIEW that you want to create in MySQL.  WHERE conditions: It is also optional. It specifies the conditions that must be met for the records to be included in the VIEW. II. DISPLAY VIEW Syntax: SELECT * FROM VIEW_NAME; III. UPDATE VIEW  ALTER VIEW statement is used to modify or update the already created VIEW without dropping it. Syntax: alter view view_name as select columns from table where conditions; IV. DROP VIEW Syntax: drop view [if exists] view_name; Parameters:  view_name: It specifies the name of the VIEW that you want to drop.
  • 55. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 42 | P a g e  IF EXISTS: It is optional. If you do not specify this clause and the VIEW doesn't exist, the DROP VIEW statement will return an error. SQL SEQUENCES  A sequence is a set of integers 1, 2, 3, ... that are generated in order on a specific demand.  Sequences are frequently used in the databases because many applications require each row in a table to contain a unique value and sequences provide an easy way to generate them. AUTO_INCREMENT Column Syntax: create table tableName (columnName datatype NOT NULL AUTO_INCREMENT = value, ...); DATABASE: flight_header Columnname Datatype Size flight_id number Primary key flight_name varchar2 25 ticket_header Columnname Datatype Size flight_id number Foreign key ticket_no number Foreign key origin varchar2 30 destination varchar2 30 no_of_adults number no_of_children number ticket_detail Columnname Datatype Size ticket_no number Primary key name varchar2 gender varchar2 age number fare number
  • 56. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 43 | P a g e ER DIAGRAM:
  • 57. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 44 | P a g e QUERY: a. Create the following table (use sequence in flight_id in flight_header table)
  • 58. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 45 | P a g e i. Display the ticket number from both ticket_header and ticket_detail ii. Display only the common flight_id that are present in flight_header and ticket_header iii. Display the flight that is not booked iv. Create a view for the ticket_header table and display the number of details in the view v. Create a view to display the passengar detail of the flight having id 03
  • 59. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 46 | P a g e vi. Create a view for ticket_detail having flight id 01 and display the total amount earned by flight 01 from view vii. Create a view to display the name of the flight booked by the person alice viii. Create a view to display the name of the person how is youngest in the ticket_detail table
  • 60. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 47 | P a g e ix. Create a view to display the flight name starting with letter ‘k’ x. Create a view to display the total passenger and flight id for each flight xi. Alter the view created in Q.x. to display the total fare collected in each flight
  • 61. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 48 | P a g e Rubrics Mark ER Diagram [20] Query Logic [10] [Viva] Query Writing [30] Compilation [20] Record Submission [20] Total (100) Signature RESULT: Thus, queries using views, synonyms and sequences are written and executed successfully.
  • 62. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 49 | P a g e Ex. No. 7 Date: WORKING WITH PROCEDURES Page No. AIM: To write queries using PL/SQL procedures. QUERY BASE:  A procedure can return one or more than one value through parameters or may not return at all. The procedure can be used in SQL queries. I. CREATING PROCEDURE Syntax CREATE PROCEDURE procedure_name[ (parameter datatype [, parameter datatype]) ] BEGIN Declaration_section Executable_section END; Parameter:  procedure_name: name of the procedure.  Parameter: number of parameters. It can be one or more than one.  declaration_section: all variables are declared.  executable_section: code for the function is written here. II. DROP A PROCEDURE  When a procedure is dropped, it is removed from the database. Syntax: Drop procedure[ IF EXISTS ] procedure_name; III. CALL A PROCEDURE mysql> call procedure_name; DATABASE: ticket_detail Columnname Datatype Size ticket_no number Primary key name varchar2 gender varchar2 age number fare number
  • 63. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 50 | P a g e ER DIAGRAM: QUERY: i. Write a procedure to display the female passenger list
  • 64. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 51 | P a g e ii. Write a procedure to display the passenger detail who are gents and having the highest ticket fare
  • 65. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 52 | P a g e iii. Write a procedure to display the name of the passengers who have age ranging from 20 to 45. Display in capital letter
  • 66. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 53 | P a g e iv. Write a procedure to display the name of the passenger who has the fare above the average fare. Display in lower case
  • 67. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 54 | P a g e v. Write a procedure to display the passenger name who is having second letter as ‘l’
  • 68. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 55 | P a g e Rubrics Mark ER Diagram [20] Query Logic [10] [Viva] Query Writing [30] Compilation [20] Record Submission [20] Total (100) Signature RESULT: Thus, queries using procedures are written and executed successfully.
  • 69. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 56 | P a g e Ex. No. 8 Date: WORKING WITH CURSORS Page No. AIM: To write queries using PL/SQL cursors. QUERY BASE: I. DECLARE CURSOR  A cursor is a select statement, defined in the declaration section in MySQL. Syntax DECLARE cursor_name CURSOR FOR Select statement; Parameter:  cursor_name: name of the cursor  select_statement: select query associated with the cursor II. OPEN CURSOR  After declaring the cursor the next step is to open the cursor using open statement. Syntax Open cursor_name; Parameter:  cursor_name: name of the cursor which is already declared. III. FETCH CURSOR  After declaring and opening the cursor, the next step is to fetch the cursor. It is used to fetch the row or the column. Syntax FETCH [ NEXT [ FROM ] ] cursor_name INTO variable_list; Parameter:  cursor_name: name of the cursor  variable_list: variables, comma separated, etc. is stored in a cursor for the result set IV. Close Cursor  The final step is to close the cursor. Syntax Close cursor_name; Parameter:  Cursor_name: name of the cursor
  • 70. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 57 | P a g e V. CALL THE CURSOR Syntax SET @name_list =""; CALL list_name(@name_list); SELECT @name_list; DATABASE: patient Columnname Datatype Size pid number Primary key pname varchar2 30 disease varchar2 20 date_of_admission Date ward_no number ER DIAGRAM:
  • 71. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 58 | P a g e QUERY: i. Write a procedure to display the patient information of the particular ward no 2
  • 72. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 59 | P a g e ii. Write a procedure to display the name of the patient who has admitted between 02.09.2010 to 25.10.2010. Display in capital letter
  • 73. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 60 | P a g e iii. Write a procedure to display the count of patients in each ward
  • 74. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 61 | P a g e iv. Write a procedure to display the patient name who is having last letter as ‘i’
  • 75. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 62 | P a g e v. Write a procedure to display the count patient with the particular disease
  • 76. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 63 | P a g e Rubrics Mark ER Diagram [20] Query Logic [10] [Viva] Query Writing [30] Compilation [20] Record Submission [20] Total (100) Signature RESULT: Thus, queries using cursors are written and executed successfully.
  • 77. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 64 | P a g e Ex. No. 9 Date: WORKING WITH FUNCTIONS Page No. AIM: To write queries using PL/SQL functions. QUERY BASE: I. CREATING A FUNCTION  A function always returns a value using the return statement. The function can be used in SQL queries. Syntax CREATE FUNCTION function_name [ (parameter datatype [, parameter datatype]) ] RETURNS return_datatype BEGIN Declaration_section Executable_section END; Parameter:  Function_name: name of the function  Parameter: number of parameter. It can be one or more than one.  return_datatype: return value datatype of the function  declaration_section: all variables are declared.  executable_section: code for the function is written here. II. DROP A FUNCTION Syntax: Drop function [ IF EXISTS ] function_name; Parameter  function_name: name of the function to be dropped.
  • 78. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 65 | P a g e DATABASE: sailors_master Columnname Datatype Size Sid number Sname varchar2 20 Rating number Age number 2,1 ER DIAGRAM: QUERY: i. Write a function to display the name of the sailor having particular sid. [get the value of sid during run time]
  • 79. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 66 | P a g e ii. Write a function to display the total number of sailor in the database iii. Write a function to display the average age of sailors with the rating 7
  • 80. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 67 | P a g e iv. Write a function to display the total number of sailors in the database having the age as 35 v. Write a function to display the youngest sailor with rating 10
  • 81. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 68 | P a g e Rubrics Mark ER Diagram [20] Query Logic [10] [Viva] Query Writing [30] Compilation [20] Record Submission [20] Total (100) Signature RESULT: Thus, queries using functions are written and executed successfully.
  • 82. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 69 | P a g e Ex. No. 10 Date: WORKING WITH TRIGGERS Page No. AIM: To write queries using PL/SQL triggers. QUERY BASE: 1. AFTER/BEFORE INSERT Trigger  AFTER/BEFORE trigger means trigger will invoke after the record is inserted. Syntax CREATE TRIGGER trigger_name AFTER/BEFORE INSERT ON table_name FOR EACH ROW BEGIN --variable declarations --trigger code END; Parameter:  trigger_name: name of the trigger to be created.  AFTER/BEFORE INSERT: It points the trigger after or before insert query is executed  table_name: name of the table in which a trigger is created. 2. AFTER/ BEFORE UPDATE Trigger  AFTER/BEFORE UPDATE trigger means trigger will invoke after/before the record is updated. Syntax CREATE TRIGGER trigger_name AFTER/BEFORE UPDATE ON table_name FOR EACH ROW BEGIN --variable declarations --trigger code END; Parameter:  trigger_name: name of the trigger to be created.
  • 83. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 70 | P a g e  AFTER UPDATE: It points the trigger update query is executed.  table_name: name of the table in which a trigger is created. 3. AFTER/BEFORE DELETE Trigger  AFTER/BEFORE DELETE trigger means trigger will invoke after/before the record is deleted. Syntax CREATE TRIGGER trigger_name AFTER/BEFORE DELETE ON table_name FOR EACH ROW BEGIN --variable declarations --trigger code END; Parameter:  trigger_name: name of the trigger to be created.  AFTER/BEFORE DELETE: It points the trigger after/before delete query is executed.  table_name: name of the table in which a trigger is created. 4. DROP TRIGGER  When Trigger drops, then it is removed from the database. Syntax Drop Trigger[ IF EXISTS ] Trigger_name; Parameter:  Trigger_name: Name of the Trigger to be dropped DATABASE: Employee Columnname Datatype Size eno number Primary key ename varchar2 30 designation varchar2 30 age number address varchar2 30 salary number
  • 84. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 71 | P a g e ER DIAGRAM: QUERY: i. Write a trigger to display the salary difference between old salary and new salary. [Show when insertion and updation]
  • 85. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 72 | P a g e ii. Write a trigger to prevent truncating a table.
  • 86. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 73 | P a g e iii. Write a trigger to insert the record of deleted employee details with deleted date.
  • 87. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 74 | P a g e iv. Write a trigger to insert old salary records of an employee once the salary is updated
  • 88. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 75 | P a g e v. Write a trigger to raise an application error if the detail of an employee with designation as 'Manager' is deleted.
  • 89. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 76 | P a g e Rubrics Mark ER Diagram [20] Query Logic [10] [Viva] Query Writing [30] Compilation [20] Record Submission [20] Total (100) Signature RESULT: Thus, queries using triggers are written and executed successfully.
  • 90. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 77 | P a g e Ex. No. 11 Date: WORKING WITH EXCEPTION Page No. AIM: To write queries using PL/SQL exception. QUERY BASE:  An error condition during a program execution is called an exception and the mechanism for resolving such an exception is known as an exception handler. Syntax DECLARE <declarations section> BEGIN <executable command(s)> EXCEPTION <exception handling goes here > WHEN exception1 THEN exception1-handling-statements WHEN exception2 THEN exception2-handling-statements WHEN exception3 THEN exception3-handling-statements ........ WHEN others THEN exception3-handling-statements END; RAISING EXCEPTIONS  Exceptions are raised by the database server automatically whenever there is any internal database error, but exceptions can be raised explicitly by the programmer by using the command RAISE. DECLARE exception_name EXCEPTION; BEGIN IF condition THEN RAISE exception_name;
  • 91. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 78 | P a g e END IF; EXCEPTION WHEN exception_name THEN statement; END; CREATING USER DEFINED EXCEPTION Syntax DECLARE my-exception EXCEPTION; DATABASE: book Columnname Datatype Size Bid Number Bname Varchar2 30 Author Varchar2 30 Edition Number Price Number ER DIAGRAM:
  • 92. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 79 | P a g e QUERY: i. Write an exception code if the price of the code does not satisfy the constraint
  • 93. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 80 | P a g e ii. Write an exception code to raise exception when trying to access an empty book table
  • 94. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 81 | P a g e iii. Write an exception code to raise an exception when no such book is found
  • 95. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 82 | P a g e iv. Write a user defined exception code if the book has second edition
  • 96. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 83 | P a g e Rubrics Mark ER Diagram [20] Query Logic [10] [Viva] Query Writing [30] Compilation [20] Record Submission [20] Total (100) Signature RESULT: Thus, queries using exception are written and executed successfully.
  • 97. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 84 | P a g e Ex. No. 12 Date: CASE STUDY USING REAL LIFE DATA BASE APPLICATIONS Page No. AIM: To perform case study for any real life database applications. CASE STUDY: PROBLEM STATEMENT:
  • 98. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 85 | P a g e SOLUTION:
  • 99. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 86 | P a g e
  • 100. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 87 | P a g e
  • 101. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 88 | P a g e CONCLUSION:
  • 102. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 89 | P a g e Rubrics Mark Scope [20] Originality [30] Presentation [30] Conclusions and Recommendations [20] Total (100) Signature RESULT: Thus, case study for real life database application is done.
  • 103. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 90 | P a g e Ex. No. 13 Date: STUDY OF PHP Page No. AIM: To study PHP for front end design and back end connectivity. BASICS:  PHP is a server side scripting language.  PHP is an interpreted language, i.e. there is no need for compilation.  PHP is an object-oriented language.  PHP is an open-source scripting language.  PHP is simple and easy to learn language. Syntax: <?php //your code here ?> DATA TYPES  PHP data types are used to hold different types of data or values. PHP supports 8 primitive data types that can be categorized further in 3 types: o Scalar Types o Compound Types o Special Types PHP Data Types: Scalar Types There are 4 scalar data types in PHP. o boolean o integer o float o string PHP Data Types: Compound Types There are 2 compound data types in PHP. o array o object PHP Data Types: Special Types There are 2 special data types in PHP. o resource
  • 104. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 91 | P a g e o NULL PHP OPERATORS  Arithmetic Operators  Comparison Operators  Bitwise Operators  Logical Operators  String Operators  Incrementing/Decrementing Operators  Array Operators  Type Operators  Execution Operators  Error Control Operators  Assignment Operators We can also categorize operators on behalf of operands. They can be categorized in 3 forms:  Unary Operators: works on single operands such as ++, -- etc.  Binary Operators: works on two operands such as binary +, -, *, / etc.  Ternary Operators: works on three operands such as "?:". PHP CONTROL STATEMENTS  Branching o if else o switch  Looping o for o while o do..while  Unconditional Statement o Break PHP ARRAYS Syntax $variable = array(values separated in commas); PHP WITH MYSQL PHP mysqli_connect()
  • 105. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 92 | P a g e o PHP mysqli_connect() function is used to connect with MySQL database. It returns resource if connection is established or null. Syntax resource mysqli_connect (server, username, password) PHP mysqli_close() o PHP mysqli_close() function is used to disconnect with MySQL database. It returns true if connection is closed or false. Syntax bool mysqli_close(resource $resource_link) PHP MySQLi Create Database Example <?php $host = 'localhost:3306'; $user = ''; $pass = ''; $conn = mysqli_connect($host, $user, $pass); if(! $conn ) { die('Could not connect: ' . mysqli_connect_error()); } echo 'Connected successfully<br/>'; $sql = 'CREATE Database mydb'; if(mysqli_query( $conn,$sql)){ echo "Database mydb created successfully."; }else{ echo "Sorry, database creation failed ".mysqli_error($conn); } mysqli_close($conn); ?> MySQLi Create Table Example <?php $host = 'localhost:3306'; $user = '';
  • 106. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 93 | P a g e $pass = ''; $dbname = 'test'; $conn = mysqli_connect($host, $user, $pass,$dbname); if(!$conn){ die('Could not connect: '.mysqli_connect_error()); } echo 'Connected successfully<br/>'; $sql = "create table emp5(id INT AUTO_INCREMENT,name VARCHAR(20) NOT NULL, emp_salary INT NOT NULL,primary key (id))"; if(mysqli_query($conn, $sql)){ echo "Table emp5 created successfully"; }else{ echo "Could not create table: ". mysqli_error($conn); } mysqli_close($conn); ?> PHP MySQLi Insert Record Example Example <?php $host = 'localhost:3306'; $user = ''; $pass = ''; $dbname = 'test'; $conn = mysqli_connect($host, $user, $pass,$dbname); if(!$conn){ die('Could not connect: '.mysqli_connect_error()); } echo 'Connected successfully<br/>'; $sql = 'INSERT INTO emp4(name,salary) VALUES ("sonoo", 9000)';
  • 107. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 94 | P a g e if(mysqli_query($conn, $sql)){ echo "Record inserted successfully"; }else{ echo "Could not insert record: ". mysqli_error($conn); } mysqli_close($conn); ?> PHP MySQLi Update Record Example <?php $host = 'localhost:3306'; $user = ''; $pass = ''; $dbname = 'test'; $conn = mysqli_connect($host, $user, $pass,$dbname); if(!$conn){ die('Could not connect: '.mysqli_connect_error()); } echo 'Connected successfully<br/>'; $id=2; $name="Rahul"; $salary=80000; $sql = "update emp4 set name="$name", salary=$salary where id=$id"; if(mysqli_query($conn, $sql)){ echo "Record updated successfully"; }else{ echo "Could not update record: ". mysqli_error($conn); } mysqli_close($conn); ?> PHP MySQLi Delete Record Example
  • 108. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 95 | P a g e Example <?php $host = 'localhost:3306'; $user = ''; $pass = ''; $dbname = 'test'; $conn = mysqli_connect($host, $user, $pass,$dbname); if(!$conn){ die('Could not connect: '.mysqli_connect_error()); } echo 'Connected successfully<br/>'; $id=2; $sql = "delete from emp4 where id=$id"; if(mysqli_query($conn, $sql)){ echo "Record deleted successfully"; }else{ echo "Could not deleted record: ". mysqli_error($conn); } mysqli_close($conn); ?> PHP MySQLi Select Query Example <?php $host = 'localhost:3306'; $user = ''; $pass = ''; $dbname = 'test'; $conn = mysqli_connect($host, $user, $pass,$dbname); if(!$conn){ die('Could not connect: '.mysqli_connect_error()); } echo 'Connected successfully<br/>';
  • 109. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 96 | P a g e $sql = 'SELECT * FROM emp4'; $retval=mysqli_query($conn, $sql); if(mysqli_num_rows($retval) > 0){ while($row = mysqli_fetch_assoc($retval)){ echo "EMP ID :{$row['id']} <br> ". "EMP NAME : {$row['name']} <br> ". "EMP SALARY : {$row['salary']} <br> ". "--------------------------------<br>"; } //end of while }else{ echo "0 results"; } mysqli_close($conn); ?> PHP MySQLi Order by Example Example <?php $host = 'localhost:3306'; $user = ''; $pass = ''; $dbname = 'test'; $conn = mysqli_connect($host, $user, $pass,$dbname); if(!$conn){ die('Could not connect: '.mysqli_connect_error()); } echo 'Connected successfully<br/>'; $sql = 'SELECT * FROM emp4 order by name'; $retval=mysqli_query($conn, $sql); if(mysqli_num_rows($retval) > 0){ while($row = mysqli_fetch_assoc($retval)){
  • 110. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 97 | P a g e echo "EMP ID :{$row['id']} <br> ". "EMP NAME : {$row['name']} <br> ". "EMP SALARY : {$row['salary']} <br> ". "--------------------------------<br>"; } //end of while }else{ echo "0 results"; } mysqli_close($conn); ?> RESULT: Thus, basics for designing and database connectivity using PHP is done
  • 111. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 98 | P a g e Ex. No. 14 Date: ER MODELLING, NORMALIZATION OF DATABASE AND FONT END DESIGN FOR MINI PROJECT Page No. MINI PROJECT TITLE: OBJECTIVE: ROUGH DRAFT DATABASE:
  • 112. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 99 | P a g e ER MODEL
  • 113. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 100 | P a g e NORMALIZATION
  • 114. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 101 | P a g e
  • 115. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 102 | P a g e TABLE DESIGN
  • 116. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 103 | P a g e FRONT END DESIGN
  • 117. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 104 | P a g e
  • 118. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 105 | P a g e Rubrics Mark Objective [20] Drawing ER Modeling [20] Normalization [30] Layout /Design [20] Navigation /Links [20] Total [100] Signature RESULT: Thus, case study for real life database application is done.
  • 119. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 106 | P a g e Ex. No. 15 Date: FRONT END DESIGN, IMPLEMENTATION AND CONNECTING WITH BACK END Page No. CONNECTION STRING SCREEN SHOTS
  • 120. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 107 | P a g e
  • 121. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 108 | P a g e
  • 122. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 109 | P a g e CONCLUSION: FUTURE ENHANCEMENT:
  • 123. CS8481 - DATABASE MANAGEMENT SYSTEMS LABORATORY 2019 - 2020 (EVEN) 110 | P a g e Rubrics Mark Contributions [10] Code Design [30] Database Connectivity [30] Conclusions and Recommendations [20] Documentation [10] Total [100] Signature