You are on page 1of 27

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

RAGHU ENGINEERING COLLEGE


(Autonomous)
Accredited by NAAC and NBA, Affiliated to JNTU-Kakinada Dakamarri
(V), Bheemunipatnam (M),
Visakhapatnam – 531162
2020-21

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)

P.MANOJ M.LAKSHMI BHASKAR


(Regd No: 19981A05C3) (Regd No: 20985A0511)

Under the esteemed guidance of


Mrs.P.Ratna kumari

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

This is to certify that this project entitled “SHIPPING CORPORATION ” done


by K.MOUNIKA, K.VASANTHI, P.MANOJ, M.LAKSHMI BHASKAR
bearing Regd. No: 19981A0579, 19981A0583, 19981A05C3, 20985A0511, during
the academic year 2020-2021 in partial fulfillment of the requirements for the
completion of fourth semester of Bachelor of Technology in Computer Science And
Engineering, under the supervision of Mrs.P.Ratna kumari , Assistant Professor,
CSE.

Internal Guide Head Of TheDepartment


Mrs.P.Ratna kumari Mr. S. SRINADHRAJU

Department of CSE, Department of CSE,


Raghu Engineering College. Raghu Engineering College.

EXTERNAL EXAMINER

4
DECLARATION

This is to certify that this project titled “SHIPPING CORPORATION” is


bonafide work done by us, in partial fulfillment of the requirements for the
completion of fourth semester of the degree B.Tech and submitted to the
Department of Computer Science & Engineering, Raghu Engineering College,
Dakkamarri. We also declare that this project is a result of our own effort and that
has not been copied from anyone and we have taken only citations from the sources
which are mentioned in the references

K .MOUNIKA K.VASANTHI

P.MANOJ M.LAKSHMI BHASKAR

PLACE: REC, Visakhapatnam DATE:

5
TABLE OF CONTENTS

S.NO CONTENT PAGE NUMBER

1 Project Statement 5

2 Project Description 6

3 Concepts used 7-8

4 Source Code And Screenshots 9-26

5 References 27

4|Page
1. STATEMENT

Create a database to store information of a shipping corporation like the boats


information used in the corporation and the boats that are reserved by the
passengers and also maintain the sailors information who will run these boats .

5|Page
2. DESCRIPTION

DBMS stands for Database Management System. . Database is a collection


of data and Management System is a set of programs to store and retrieve those
data. DBMS is a collection of inter-related data and set of programs to store and
access those data in an easy effective manner.

The project is implemented using MySQL database.Database is used to store


information of a shipping corporation like the boats information that used in the
corporation and the boats that are reserved by the passengers and also maintain
the sailors information who will run these boats. It gives all the information about
boats and sailors and reserves .

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 ;

ALTER TABLE Command:


ALTER TABLE ADD COLUMN ATT_NAME
DATATYPE;

Adding data to the Table :-


We can add data to table by using INSERT INTO command.
While adding the data to the table we must remember the order of attributes as
well as their data types as defined while creating table. The syntax is as follows.
INSERT INTO VALUES (VALUE1, VALUE2, VALUE3, …..);

UPDATE command.:UPDATE SET ATT_NAME = NEW_VALUE WHERE


CONDITION;

UNION :- It is a set operator used as alternative to OR query

INTERSECT :- It is a set operator used as alternative to AND query. Here is an


example of Query using AND.

EXCEPT (MINUS) :- It is a set operator used as set-difference. Our next query


illustrates the setdifference operation.

IN Operator :- The IN operator allows us to test whether a value is in a given set


of elements;
NOT IN Operator :- The NOT IN is used in a opposite manner to IN.
COUNT (A) :- The number of values in the A column
SUM (A) :- The sum of all values in the A column
AVG (A) :- The average of all values in the A column

LOWER(CHAR) :- Converts all characters to lowercase characters in a sting


CHAR
UPPER(CHAR) :- Converts all characters to uppercase characters in a sting
CHAR.

7|Page
ENTITY-RELATIONSHIP DAIGRAM:

Sailors:

Boats:

Reserves:

8|Page
4.SOURCE CODE AND OUTPUTS

CREATE TABLE boats


(
bid integer,
bname varchar(20),
color varchar(20)
);

OUTPUT:

insert into boats values(101,'interlake','blue');


insert into boats values(102,'interlake','red');
insert into boats values(103,'clipper','green');
insert into boats values(104,'marine','red');

9|Page
OUTPUT:

select * from boats

OUTPUT:

Select bid from boats

10 | P a g e
UPDATE:

update boats
set color = 'BLACK'
where bid = 103

ALTER:

alter table boats


add boat_no number(10);

output:

CREATE TABLE sailors


(
sid integer,
sname varchar(20),
rating integer,
age integer
);

11 | P a g e
OUTPUT:

insert into sailors values(22,'dustin',7,45);


insert into sailors values(29,'brutus',1,33);
insert into sailors values(31,'lubber',79,55);
insert into sailors values(32,'andy',8,25);
insert into sailors values(58,'rusty',10,35);
insert into sailors values(58,'buplb',10,35);
insert into sailors values(58,'buplerb',10,35);
insert into sailors values(22,'bb',10,35);

12 | P a g e
OUTPUT:

select * from sailors

13 | P a g e
RENAME:
alter table sailors rename to sail_age

OUTPUT:

select * from sail_age

OUTPUT:

14 | P a g e
CREATE TABLE reserves
(
sid integer,
bid integer,
day1 date
);

OUTPUT:

insert into reserves values('22','102','22-may-21');


insert into reserves values('22','103','30-may-21');
insert into reserves values('22','105','25-may-21');
insert into reserves values('31','103','20-may-21');
insert into reserves values('32','104','15-may-21');

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

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
AND b.color='red'
WHERE r.sid IN(
SELECT 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:

• Find the sids of all sailors who have reserved red boats but not green boats.

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
AND b.color='red'
WHERE r.sid NOT IN(
SELECT 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:

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.

SELECT S.SNAME FROM SAILORS S, RESERVES R, BOATS B

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.

SELECT R1.SID FROM BOATS B1, RESERVES R1 WHERE R1.BID =


B1.BID AND
B1.COLOR = 'red';
MINUS
SELECT R2.SID FROM BOATS B2, RESERVES R2 WHERE R2.BID =
B2.BID AND
B2.COLOR = ‘green’;

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

SELECT S.RATING, MIN (S.AGE) AS MINAGE FROM SAILORS


S WHERE S.AGE >= 18
GROUP BY S.RATING HAVING COUNT (*) > 1;

OUTPUT:

NESTED QUERIES:-
IN Operator:
Find the names of sailors who have reserved boat 103 using IN Operator.

SELECT S.SNAME FROM SAILORS S WHERE S.SID


IN (SELECT R.SID FROM RESERVES R WHERE R.BID = 103 );

OUTPUT:

22 | P a g e
NOT IN Operator :-
Find the names of sailors who have not reserved boat 103 using NOT IN
Operator.

SELECT S.SNAME FROM SAILORS S WHERE S.SID


NOT IN (SELECT R.SID FROM RESERVES R WHERE R.BID = 103 );

OUTPUT:

SUM (A):

SELECT SUM (RATING)


FROM SAILORS;

OUTPUT:

ORDER BY Clause:

Display all the sailors according to their ages


SELECT * FROM SAILORS ORDER BY AGE

OUTPUT:

23 | P a g e
Concatenation:
• Concat bid & bname of Boats & display along with color.

SELECT CONCAT (BID, BNAME), COLOR FROM BOATS;

OUTPUT:

LTRIM:

SELECT SID, LTRIM (SNAME,'r') FROM


SAILORS;

OUTPUT:

24 | P a g e
RTRIM:
SELECT SID, RTRIM (SNAME,'i') FROM SAILORS;

OUTPUT:

LOWER(CHAR):

SELECT BID, LOWER (BNAME), COLOR FROM BOATS;

OUTPUT:

25 | P a g e
UPPER(CHAR):

SELECT SID, UPPER (SNAME), AGE, RATING FROM SAILORS;

OUTPUT:

26 | P a g e
5.REFERENCE

https://www.codersarts.com

27 | P a g e

You might also like