561 views

1 Answer

2 votes
2 votes

ANSWER: $Q_1$, $Q_2$ and $Q_3$


EXPLANATION

Natural Join is a type of cartesian product whose selection of tuples is based on common columns of two table.  

Outer Join considers all the tuples from both the table and join them with specified attribute. Null in case of no join of tuples possible.


SQL COMMANDS 

CREATE TABLE PSNGR(
    Pass_No varchar(2),
    Pass_Name varchar(10),
    TNo varchar(2)
);

CREATE TABLE TRN(
    TNo varchar(2),
    Type varchar(3)
);

INSERT INTO PSNGR VALUES
    ('P1','Mallesham','T4'),
    ('P2','Suresh','T3'),
    ('P3','Anirudh','T3'),
    ('P4','Shiva','T1');
    
INSERT INTO TRN VALUES
    ('T1','SFA'),
    ('T2','EXP'),
    ('T3','SHA'),
    ('T4','RAJ');

SELECT PSNGR.Pass_Name,PSNGR.TNo, Type 
    FROM PSNGR CROSS JOIN TRN
    WHERE PSNGR.TNo = TRN.TNo 
        AND TRN.Type = 'SHA';

SELECT PSNGR.Pass_Name,PSNGR.TNo, Type
    FROM PSNGR NATURAL JOIN TRN
    WHERE TRN.Type = 'SHA';

SELECT PSNGR.Pass_Name,PSNGR.TNo, Type
    FROM PSNGR JOIN TRN
    ON PSNGR.TNo = TRN.TNo
    WHERE Type = 'SHA';

Output of the three select statement -

EDIT:

Result of $Q_3$ becomes clearer with the following query 

SELECT PSNGR.Pass_Name,PSNGR.TNo, Type
    FROM PSNGR JOIN TRN
    ON PSNGR.TNo = TRN.TNo;

Related questions

6 votes
6 votes
2 answers
1
hacker16 asked Jan 9, 2018
3,817 views
Why is the minimum number of tuples in full outer join equal to max (m,n) ?
5 votes
5 votes
4 answers
2
learncp asked Sep 5, 2015
3,424 views
Why is the maximum number of tuples in full outer join equal to m*n, where m is the number of attributes in one relation and n is the attribute count in other ?Can someon...
0 votes
0 votes
1 answer
3
Chirag arora asked Jun 29, 2018
431 views
Can any one explain this question
1 votes
1 votes
1 answer
4
atulcse asked Oct 31, 2021
437 views
An outer join can be done between:a. only two tables b. only three tables c. any number of tables