0% found this document useful (0 votes)
3K views

DMS Model-Answer-Paper-Summer-2023

Uploaded by

anupatil7576
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views

DMS Model-Answer-Paper-Summer-2023

Uploaded by

anupatil7576
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION

(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

Important Instructions to examiners:


1) The answers should be examined by key words and not as word-to-word as given in themodel answer
scheme.
2) The model answer and the answer written by candidate may vary but the examiner may tryto assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given moreImportance (Not
applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in thefigure. The
figures drawn by candidate and model answer may vary. The examiner may give credit for any equivalent
figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may
vary and there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based
on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent
concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual
(English + Marathi) medium is introduced at first year of AICTE diploma Programme from academic year
2021-2022. Hence if the students in first year (first and second semesters) write answers in Marathi or
bilingual language (English +Marathi), the Examiner shall consider the same and assess the answer based
on matching of concepts with model answer.

Q. Sub Answer Markin


No Q. No g
Scheme

1 Attempt any FIVE of the following: 10M


a) Define the following terms:
i) Database 2M
ii) DBMS Definition
Ans i) Database: Database is collection of data, which is organized in such a way that 1M each
it can be easily accessed, managed or updated.
ii) DBMS: Database Management System is software that used to manage,
storage, access and security of data.
OR
DBMS: Database management system is a large software package that controls the
specification, organization, storage, retrieval and update of data in a database.
b) List any four codd’s rules 2M
Ans 1. The Information rule
Any four
2. The Guaranteed Access rule valid rules
3. The Systematic Treatment of Null Values rule 1/2M
4. Relational Model rule each

5. The Comprehensive Data Sublanguage rule


6. The View Updating rule

Page 1 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

7. The High-level Insert, Update, and Delete rule


8. The Physical Data Independence rule
9. The Logical Data Independence rule
10. The Integrity Independence rule
11. The Distribution Independence rule
12. The No subversion rule
c) Explain subquery concept with example 2M
Ans Subquery : A subquery is a query which is embedded within another query. The
Explanati
outer query is called as main query and inner query is called as subquery on 1M

Example
For Example: 1M
Select * from customer where age = ( Select min(age) from customer );
The above query will select all rows from customer table with minimum age.

d) Define 2M
i) Primary Key
ii) Candidate Key
Ans Primary Key : A primary key is the column or columns that contain values that 1M for
uniquely identify each row in a table. A primary key does not allow duplicate each
values and null values. definition

Candidate Key: The minimal set of attributes that can uniquely identify a tuple is
known as a candidate key. A table can have multiple candidate keys, but can only
have one primary key.

e) List any two DDL commands with syntax 2M


Ans DDL commands
Any two
1.Create DDL
Syntax : command
create table (Column_name1 datatype1(size1), column_name2 Datatype 2(size2), s with
syntax 1M
…Column_nameN DatatypeN(size n)); each
2. Drop
Syntax:
drop table < table_name>;
3. Desc
Syntax: describe < table_name> ;
OR
Desc < table_name> ;
4. Truncate
Syntax: truncate table < table_name> ;

Page 2 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

5. Alter
Syntax: i) Alter table < table_name> add (Column_name Datatype (size));
ii)Alter table <table_name> drop(Column_name);
iii)Alter table <table_name> rename column(old column_name to new
column_name);

f) Draw the block structure of PL-SQL 2M


Ans
Correct
Diagram
2M

g) State syntax of while loop command 2M


Ans Syntax :
Correct
WHILE <condition> syntax 2M
LOOP statements;
END LOOP;
2 Attempt any THREE of the following 12M
a) Explain not null and check constraint with example. 4M
Ans Not Null Constraint:
Each
The Not Null constraint is used to ensure that a given column of a table is never constraint
assigned the null value. with
Example: example
2M
CREATE TABLE student
(
Rollno number(4) constraint NN NOT NULL,
Name varchar(255) ,
Marks number(3)
);
Check Constraint:
The Check constraint is used to limit the value range that can be placed in a
column.
Example:
CREATE TABLE student
(

Page 3 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

Rollno number(4),
Name varchar(255),
Marks number(3),
Age number(3) constraint ck CHECK (Age>=18)
);

b) Explain any four string functions with example 4M


Ans 1. Lower(char)- Returns the input string with all letters in lower case.
Any four
Example: SQL>Select lower („RAJESH‟) from dual; string
Output: rajesh function
2. Upper(char)- Returns the input string with all letters in upper case. with
example
Example: SQL>Select upper („rajesh‟) from dual; 1M each
Output: RAJESH
3. Ltrim(char,set)- It removes or trims from left of character string .
Example: SQL>Select Ltrim(„university‟,‟univ‟) from dual;
Output: ersity
4. Rtrim(char,set)- It removes or trims from right of character string.
Example: SQL>Select Rtrim(„university‟,‟sity‟) from dual;
Output: univer
5. Length(char)- It returns length of character string.
Example: SQL> Select length(„University‟) from dual;
Output:10
6. Concat(str1,str2,...)- Returns the string that result from concatenating
the arguments.
Example: Select Concat(„employee‟, „name‟) from dual;
Output: employeename
7. Lpad(str, len, padstr)- Returns the string str, left-padded with the
string padstr to a length of len characters.
Example: Select lpad(ename,10,‟*‟) from emp where
empno=7782; OR Select lpad(„MSBTE‟,12,‟*‟) from dual;
8. Rpad(str,len,padstr)- Returns the string str, right-padded with the string
padstr to a length of len characters.
Example: Select rpad(ename,10,‟*‟) from emp where empno=7782;
OR Select rpad(„MSBTE‟,12,‟*‟) from dual;
9. Substr(Char,m,n)- It returns a portion of char, beginning at a character m,
n character long.
Example: Select substr(„College‟,3,4) from dual;
Output: lleg

Page 4 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

c) Describe Grant and Revoke commands with example 4M


Ans Grant: This command is used to give permission to user to do operations on the
Each
other user‟s object. command
Syntax: Grant <object privileges> on <object name> to <User/Public/Role>[with with
grant option]; example
2M
Example: Grant select, update on emp to user1;
Revoke: This command is used to withdraw the privilege that has been granted to
a user.
Syntax: Revoke <object privileges> on <object name> from <<User/Public/Role>;
Example: Revoke select, update on emp from user1;

d) Explain trigger with suitable example 4M


Ans Trigger:
Correct
Triggers are stored programs, which are automatically executed or fired when explanati
some events occur. Triggers are, in fact, written to be executed in response to any on 2M
of the following events - Any
A database manipulation (DML) statement (DELETE, INSERT, or UPDATE) relevant
example
A database definition (DDL) statement (CREATE, ALTER, or DROP).
2M
Triggers can be defined on the table, view, schema, or database with which the
event is associated. a

For Example:
create trigger trigger_update
on emp
after update
as begin Select * from employee;
end;
The above trigger will invoke after update of record in emp table.

3 Attempt any THREE of the following 12M


a) Explain views with example 4M
Ans A view is a logical table based on another table.View logically represents subsets
of data from one or more tables .A view contains no data of it‟s own but is like a
Explanati
window through which data from tables can be viewed or changed .The tables on on
which the view is based are called base tables. 2M
SQL functions, where, join statements can be added to a view and the data in it
Example
can be presented as if it were from one table. 2M
The database engine recreates the data, using the view‟s SQL statement, every
time a user queries a view. A view can be updated using the create or replace
view command. For deleting a view, dropquery can be used.

Page 5 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

General syntax to create a view:


create view viewname as select query.
Example:
create view vw_student as select stud_id, stud_name,ssc_per
from student;

b) Explain properties of transaction 4M


Ans A transaction can be defined as a group of tasks. A single task is the minimum
Four
processing unit which cannot be divided further. properties
ACID Properties 1M each
A transaction is a very small unit of a program and it may contain several low
level tasks. A transaction in a database system must
maintain Atomicity, Consistency, Isolation, and Durability −commonly known as
ACID properties − in order to ensure accuracy, completeness, and data integrity.

 Atomicity: This property states that a transaction must be treated as an


atomic unit, that is, either all of its operations are executed or none. There must
be no state in a database where a transaction is left partially completed. States
should be defined either before the execution of the transaction or after the
execution/abortion/failure of the transaction.

 Consistency: The database must remain in a consistent state after any


transaction. No transaction should have any adverse effect on the data residing
in the database. If the database was in a consistent state before the execution of
a transaction, it must remain consistent after the execution of the transaction as
well.

 Isolation: In a database system where more than one transactions are being
executed simultaneously and in parallel, the property of isolation states that all
the transactions will be carried out and executed as if it is the only transaction
in the system. No transaction will affect the existence of any other transaction.

 Durability: The database should be durable enough to hold all its latest
updates even if the system fails or restarts. If a transaction updates a chunk of
data in a database and commits, then the database will hold the modified data.
If a transaction commits but the system fails before the data could be written on
to the disk, then that data will be updated once the system springs back into
action.

Page 6 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

c) Write step by step syntax to create, open, and close cursor in PL/SQL 4M
Ans A cursor is a temporary work area created in system memory when an SQL
2M for
statement is executed. A cursor is a set of rows together with a pointer that Create
identifies a current row. It is a database object to retrieve data from result set on
1M for
row at a time. Open
Steps:
1M for
1. Declare cursor: This refers to initialize the cursor with an associative select Close
statement. This is done in the declaration section of PL/SQL program. Before
using an explicit cursor, you must declare it in the declaration section of a block
or package as follows:
CURSOR cursor_name IS query;
2. Open: This refers to allocate the memory for the cursor. This step is done
before the cursor is used to fetch the records. Before start fetching rows from the
cursor, you must open it. To open a cursor, you use the following syntax:
OPEN cursor_name;
3. Close: This refers to release the allocated cursor. Once the processing of the
data is done, the cursor can be closed. After fetching all rows, you need to close
the cursor with the CLOSE statement:
CLOSE cursor_name;

d) Explain savepoint and rollback command with example. 4M


Ans Savepoint : This command is used to temporarily save a transaction so that you
Explanati
can rollback to that point whenever required. on of
Syntax : savepoint
with
Savepointsavepoint_name; example
Eg :savepoint s1; 2M
Rollback :
This command restores the database to last committed state. It is also used with
SAVEPOINT command to jump to a savepoint in an ongoing transaction.
If we have used the UPDATE command to make some changes into the database, Explanati
and realise that those changes were not required, then we can use the on of
rollback
ROLLBACK command to rollback those changes, if they were not committed with
using the COMMIT command. example
Syntax : 2M
Rollback [tosavepoint_name];
Eg Rollback to s1;
Example :
INSERT INTO class VALUES(5, 'Rahul');
COMMIT;

Page 7 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

UPDATE class SET name = 'Abhijit' WHERE id = '5';


SAVEPOINT s1;
INSERT INTO class VALUES(6, 'Chris');
Rollback to s1;
This will undone the transaction of last insert, i.e. till savepoint s1;

4 Attempt any THREE of the following 12M


a) Explain any four types of attributes with example.
4M
Ans 1. Simple Attribute: Simple attributes are those that cannot be further divided into
sub-attributes. Any 4
types
For example, roll number of a student or the employee identification number.
1M each
2. Composite Attribute: Composite attributes are made up of two or more simple
attributes.
For example, a person‟s address may be a composite attribute that is made up of
the person‟s street address, city, state, and zip code.
3. Single Valued Attribute: Single-valued attributes can only have one value.
Single-valued attributes are typically used to provide a unique identifier for an
entity and are often used in databases.
For example, a person‟s Social Security Number is a single-valued attribute.
4. Multivalued Attribute: Multivalued attributes can have more than one value.
For example, a person may have multiple email addresses or phone numbers.
5. Stored Attribute: Values of stored attributes remain constant and fixed for an
entity instance and also, and they help in deriving the derived attributes.
For example, the Age attribute can be derived from the Date of Birth attribute, and
also, the Date of birth attribute has a fixed and constant value throughout the life
of an entity. Hence, the Date of Birth attribute is a stored attribute.
6. Derived Attribute: Derived attributes are based on other attributes and are not
stored directly in the database.
For example: Consider a database of employees. Each employee has a date of
birth, and we can calculate their age which can be called as derived attribute.
b) Explain any four aggregate functions with example 4M
Ans Various Aggregate Functions are :
Any four
1) Count() : COUNT function is used to Count the number of rows in a database functions
table. It can work on both numeric and non-numeric data types. 1M each
COUNT function uses the COUNT(*) that returns the count of all the rows in a
specified table. COUNT(*) considers duplicate and Null.
Eg : Select count(*) from employee where deptno=10;
2) Sum() : Sum function is used to calculate the sum of all selected columns. It

Page 8 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

works on numeric fields only.


Eg : select sum(cost) from product;
3) 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.
Eg :select avg(cost) from product;
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.
Eg :select min(rate) from product;
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.
Eg : select max(rate) from product;
c) Explain any four DML commands with syntax and example. 4M
Ans DML commands:
Any four
 Insert - used to insert new row into table DML
 Delete- used to delete a row from the table command
with
 Update – used to modify data in the table. syntax
 Select – used to view data from a table. and
1) Insert : For adding records in table: example
We use Insert into command for adding/inserting data into table. 1M each
Syntax:
Insert into <table name> values (value1, value2, value3…);
Ex:
insert into Student values(1,‟xyz‟,‟12-Jan-1990‟,88,10);
OR
Ex:
Insert into Studentvalues(&R_No,‟&Name‟,‟&DOB‟,&Percentage,&D_No);
2) Update : For modifying records in table
We use update command for modifying data of a table.
Syntax:
Update <table name>set columnname1=expression where <condition>;
Ex:
update Student set DOB=‟22-feb-1995‟ where R_No=3;
3) Delete : For deleting records from table:
We use delete command for deleting data of a table.
Syntax:
Delete from <table name>[where <condition>];
Ex:
delete from Student where R_No=2;
4) Select : For viewing the records from table

Page 9 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

We use select command for displaying or viewing the records from a table or
tables.
Syntax:
Select <*/ list of columns> from <table name> [where <condition> ] ;

Ex :
Select * from Student;
Select R_N0,Name,DOB from Student where Percentage > 80;

d) Write a PL-SQL program to print odd numbers from 1 to 10. 4M


Ans begin
2M for
dbms_output.put_line(„Oddnos from 1 to 10 are :‟); Correct
fornum in 1..10 Logic
loop
if(mod(num,2)!=0) then
2M for
dbms_output.put_line(num); correct
end if; syntax
end loop;
end;

e) Explain the most common types of database failures. 4M


Ans Transaction Failures: Transactions can fail for a number of reasons. Failure can be
Any 2
due to an error in the transaction caused by incorrect input data as well as the types of
detection of a present or potential deadlock. Furthermore, some concurrency failure,
control algorithms do not permit a transaction to proceed or even to wait if the 2M each
data that they attempt to access are currently being accessed by another
transaction. This might also be considered a failure.
1. System Failures( or Hardware/ Software failure): The reasons for system
failure can be traced back to a hardware or to a software failure.
2. Media Failures: Media failure refers to the failures of the secondary storage
devices that store the database. Such failures may be due to operating system
errors, as well as to hardware faults such as head crashes or controller failures.
3. Communication/Network Failures: There are a number of types of
communication failures. The most common ones are the errors in the
messages, improperly ordered messages, lost messages, and communication
line failures mainly arising due to errors in network.
5 Attempt any TWO of the following 12M
a) Explain strong and weak entity set with example. Draw ER diagram 6M
indicating strong and weak entity set.

Page 10 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

Ans Strong entity set:


Entity set that have sufficient attribute to define the primary key is called Entity set
1M
as strong entity sets.
Example
The member of strong entity set is called as dominant entity set. 1/2M
It is represented by rectangle.
The line connecting strong entity set with the relationship is single.
The relationship between two strong entity set is represented by a
diamond symbol
 A double line is used for representing the total participation of an entity
set with the relationship set. Total participation may or may not exist in
the relationship.
Example:

Student and course relation: Student entity is a strong entity because it


consists of a primary key called student id which is enough for accessing each
record uniquely. In the same way, the course entity contains of course ID attribute
which is capable of uniquely accessing each row.

Weak entity set:


Entity sets that does not have sufficient attribute to define the primary key is
called as weak entity set. Weak
 It is represented by double rectangle. Entity set
 The Member of weak entity set is called as subordinate entity set. 1M
 The line connecting weak entity set with the identifying relationship is
double.
 The relationship between one strong and a weak entity set is
represented by a doublediamond symbol.(known as identifying Example
relationship) 1/2M

 Total participation always exists in the identifying relationship.

Page 11 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

Example:
Employee is a strong entity because it has a primary key attribute called
Employee number (Employee_No) which is capable of uniquely
identifying all the employee.Unlike Employee, Dependents is weak entity
because it does not have any primary key .

Use of
correct
entities
1M

ER diagram indicating strong and weak entity set Correct


symbols
1M

Correct
relations
hips 1M

Note: Any other example can be considered


b) Explain for loop syntax in PL-SQL with example of printing 10 to 1 reverse 6M
numbers
For loop:
Ans For Loop :
explanati
 The FOR LOOP statement specifies a range of integers, then execute a on:1M,
sequence of statements once for each integer in the range.
 To reverse the range , “REVERSE” keyword is used.
 The syntax is :

Page 12 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

FOR counter IN lower_bound..upper_bound LOOP


<loop_body><loop body/statements> Syntax
END LOOP; 1M
(OR)
For counter IN [reverse] lower_bound..upper_bound LOOP
<loop body/statements>; Correct
END LOOP; Program
logic 2M
Program:
declare
a number(2); Program
Syntax
begin 2M
for a in reverse 1..10 loop
dbms_output.put_line(„value of a :‟ || a);
end loop;
end;
/
c) Explain function in PL-SQL with suitable example. 6M
Ans Function: Function is a logically grouped set of SQL and PL/SQL statements that
3M for
perform a specific task. A function is same as a procedure except that it returns a Explanati
value. A function is created using the CREATE FUNCTION statement. on
Syntax: 3M for
CREATE [OR REPLACE] FUNCTION function_name Example
[(parameter_name [IN | OUT | IN OUT] type [, ...])]
RETURN return_datatype
{IS | AS}
BEGIN
< function_body >
END [function_name];
Where,
 Function-name specifies the name of the function.
 [OR REPLACE] option allows the modification of an existing function.
 The optional parameter list contains name, mode and types of the parameters.
IN
represents the value that will be passed from outside and OUT represents the
parameter that will be used to return a value outside of the procedure.
 The function must contain a return statement.
 The RETURN clause specifies the data type you are going to return from the
function.
 function-body contains the executable part.
Page 13 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

 The AS keyword is used instead of the IS keyword for creating a standalone


function.
Example:
CREATE OR REPLACE FUNCTION Success_cnt
RETURN number
IS cnt number(7) := 0;
BEGIN
SELECT count(*) into cntFROM candidate where result='Pass';
RETURN cnt;
END; /

Note: Any other example can be considered.

6 Attempt any TWO of the following 12M


a) Draw an ER diagram of library management system considering publisher,
6M
books, members. Also show primary key, weak entity and strong entity.
Ans

Correct
symbols
1½M

Correct
relations
hips
1½M

Primary
key
1M,

Weak
entity
1M,

Strong
Entity
1M

Note: Any other entity can be added

Page 14 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

b) State and explain 1NF and 2NF with example 6M


Ans First Normal Form (1NF): A relation R is said to be in first normal form (1NF) if
Explanati
the domain of all attributes of R are atomic. on with
OR example
of 1NF
A table is in the first normal form if it contains no repeating elements groups. 3M
Example: Supplier(sno,sname,location,pno,qty)
Explanati
on with
example
of 2NF
3M

The above relation is in 1NF as all the domains are having atomic value. But it is
not in 2NF.

Second Normal Form (2NF): A relation is said to be in the second normal form if
it is in first normal form and all the non key attributes are fully functionally
dependent on the primary key.

Example: In the above relation NAME, LOCATION depends on SNO and QTY
on

(SNO, PNO) so the table can be split up into two tables as


Supplier(SNO,SNAME,LOCATION) and SP(SNO,PNO,QTY) and now both the
tables are in second normal form.

Supplier SP

Note: Any other relevant example can be considered

Page 15 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

c) Explain any two types of join with example.


Ans 6M
JOIN:
A SQL join is an instruction to combine data from two sets of data (i.e. two Explanati
tables). A on of any
two types
JOIN clause is used to combine rows from two or more tables, based on a with
related column between them. SQL Join types are as follows: example
3M each
1) EQUI JOIN:
A join which is based on equalities is called equi join. In equi join comparison
operator “=” is used to perform a Join.

Syntax:
SELECT tablename.column1_name,tablename.column2_name
FROM table_name1,table_name2
where table_name1.column_name=table_name2.column_name;
Example:
Select stud_info.stud_name, stud_info.branch_code,
branch_details.location
From stud_info, branch_details
Where Stud_info.branch_code=branch_details.branch_code;

2) SELF JOIN:
The SQL SELF JOIN is used to join a table to itself, as if the table were two
tables,temporarily renaming at least one table in the SQL statement.
Syntax:
SELECT a.column_name, b.column_name
FROM table1 a, table1 b
WHERE a.common_filed = b.common_field;
Example:
Select x.stud_name, y.stud_name
from stud_info x, stud_info y
Where x.leader= y.stud_id;

3)INNER JOIN:The INNER JOIN command returns rows that have


matching values in both tables.
Syntax:
Select column1_name,column2_name
from table1name INNER JOIN table2name
on table1name.columnname= table2name.columnname;

Page 16 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-
Subject Name: Database Management System Subject Code: 22319

Example:
Select last_name, department_name
from employees inner join departments
on employees.department_id = departments.department_id;

4) LEFT OUTER JOIN:


A left outer join retains all of the rows of the “left” table, regardless of whether
there is a row that matches on the “right” table.
Syntax:
Select column1_name,column2_name
from table1name any_alias1 ,table2name any_alias2
on any_alias1.columnname(+) = any_alias2.columnname;
OR
Select column1_name,column2_name
from table1name left outer join table2name
on table1name.columnname= table2name.columnname;
Example:
select last_name, department_name
from employees e, departments d
on e.department_id(+) = d.department_id;
OR
select last_name, department_name
from employees left outer join departments
on employees.department_id = departments.department_id;

5) RIGHT OUTER JOIN:


A right outer join retains all of the rows of the “right” table, regardless of
whether there is a row that matches on the “left” table.
Syntax:
Select column1name, column2name
from table1name any_alias1, table2name any_alias2
on any_alias1.columnname =any_alias2.columnname (+);
OR
Select column1name, column2name
from table1name any_alias1 right outer join table2 name any_alias2
on any_alias1.columnname =any_alias2.columnname;

Page 17 / 18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 2023 EXAMINATION
-

Subject Name: Database Management System Subject Code: 22319

Example:
Select last_name,department_name from employees e, departments
d on
e.department_id = d.department_id(+);
OR
Select last_name, department_name
from employees e right outer join departments d
on e.department_id = d.department_id;
6) NON EQUI JOIN:
Non equi joins is used to return result from two or more tables where exact
join is
not possible.
Syntax:
Select aliasname.column1name, aliasname.column2name from
tablename alias
where <condition using range>;
Example:
In emp table and salgrade table. The salgrade table contains grade and their
low salary and high salary. Suppose you want to find the grade of
employees based on their salaries then you can use NON EQUI join. Select
e.empno, e.ename, e.sal, s.grade
from emp e, salgrade s
where e.sal between s.lowsal and s.hisal;

Page 18 / 18

You might also like