Professional Documents
Culture Documents
SHIPPING CORPORATION
Project report submitted at the end of fourth semester
BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE AND ENGINEERING
By
K.MOUNIKA K.VASANTHI
(Regd No: 19981A0579) (Regd No:19981A0583)
Assistant Professor
3
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
RAGHU ENGINEERING COLLEGE
(Autonomous)
Accredited by NAAC and NBA, Affiliated to JNTU-Kakinada Dakamarri
(V), Bheemunipatnam (M),
Visakhapatnam
CERTIFICATE
EXTERNAL EXAMINER
4
DECLARATION
K .MOUNIKA K.VASANTHI
5
TABLE OF CONTENTS
1 Project Statement 5
2 Project Description 6
5 References 27
4|Page
1. STATEMENT
5|Page
2. DESCRIPTION
6|Page
3.CONCEPTS USED
Creating Tables :-
The CREATE TABLE command is used to create the table
(relation) in SQL. CREATE TABLE TABLENAME (ATT_NAME1
DATATYPE, ATT_NAME2 DATATYPE, ATT_NAME3 DATATYPE, …..);
Deleting Table :-
The table along with its definition & data can be deleted using
following command. DROP TABLE ;
7|Page
ENTITY-RELATIONSHIP DAIGRAM:
Sailors:
Boats:
Reserves:
8|Page
4.SOURCE CODE AND OUTPUTS
OUTPUT:
9|Page
OUTPUT:
OUTPUT:
10 | P a g e
UPDATE:
update boats
set color = 'BLACK'
where bid = 103
ALTER:
output:
11 | P a g e
OUTPUT:
12 | P a g e
OUTPUT:
13 | P a g e
RENAME:
alter table sailors rename to sail_age
OUTPUT:
OUTPUT:
14 | P a g e
CREATE TABLE reserves
(
sid integer,
bid integer,
day1 date
);
OUTPUT:
15 | P a g e
select * from reserves
OUTPUT:
16 | P a g e
• Find the names of sailors who have reserved a red boat.
SELECT s.sname
FROM sailors s
JOIN reserves r
ON r.sid=s.sid join boats b
ON r.bid=b.bid where b.color='red';
OUTPUT:
• Find the names of the Sailors who have reserved at least one boat.
SELECT sname
FROM sailors
WHERE sid
IN (
SELECT sid
FROM reserves
GROUP BY sid
);
OUTPUT:
17 | P a g e
• Find the names of sailors who have reserved a red and a green boat
OUTPUT:
• Find the sids of all sailors who have reserved red boats but not green boats.
OUTPUT:
18 | P a g e
SELECT s.sname, b.color, s.sid
FROM sailors s
JOIN reserves r ON r.sid=s.sid
JOIN boats b ON r.bid=b.bid
WHERE b.color='green';
OUTPUT:
COUNT:
SELECT COUNT(*)
FROM (
SELECT sname
FROM sailors
GROUP BY sname
) t1;
OUTPUT:
19 | P a g e
• Find the sailors with the highest rating.
SELECT COUNT(sname), rating
FROM sailors
WHERE age>18 group by rating;
OUTPUT:
UNION:
• Find all sids of sailors who have a rating of 10 or reserved boat number 1
SELECT S.SID FROM SAILORS S WHERE S.RATING = 10
UNION
SELECT R.SID FROM RESERVES R WHERE R.BID = 1;
OUTPUT:
INTERSECT:
• Find the names of sailor's who have reserved both a red and a green boat.
20 | P a g e
WHERE S.SID = R.SID AND R.BID = B.BID AND B.COLOR =‘red’;
INTERSECT
SELECT S2.SNAME FROM SAILORS S2, BOATS B2, RESERVES R2
WHERE S2.SID = R2.SID AND R2.BID = B2.BID AND B2.COLOR ='green';
OUTPUT:
MINUS:
• Find the SID of all sailors who have reserved red boats but not green boats.
OUTPUT:
GROUP BY:
• Find the age of the youngest sailor for each rating level
SELECT S.RATING, MIN (S.AGE) FROM SAILORS S GROUP BY
S.RATING;
OUTPUT:
21 | P a g e
HAVING :
• Find the age of youngest sailor with age >= 18 for each rating with at least
2 such sailors
OUTPUT:
NESTED QUERIES:-
IN Operator:
Find the names of sailors who have reserved boat 103 using IN Operator.
OUTPUT:
22 | P a g e
NOT IN Operator :-
Find the names of sailors who have not reserved boat 103 using NOT IN
Operator.
OUTPUT:
SUM (A):
OUTPUT:
ORDER BY Clause:
OUTPUT:
23 | P a g e
Concatenation:
• Concat bid & bname of Boats & display along with color.
OUTPUT:
LTRIM:
OUTPUT:
24 | P a g e
RTRIM:
SELECT SID, RTRIM (SNAME,'i') FROM SAILORS;
OUTPUT:
LOWER(CHAR):
OUTPUT:
25 | P a g e
UPPER(CHAR):
OUTPUT:
26 | P a g e
5.REFERENCE
https://www.codersarts.com
27 | P a g e