DBMS Lab Exp
DBMS Lab Exp
Sailors Relation
22 Dustin 7 45.0
29 Brutus 1 33.0
31 Lubber 8 55.5
32 Andy 8 25.5
58 Rusty 10 35.0
64 Horatio 7 35.0
71 Zorba 10 16.0
74 Horatio 9 35.0
85 Art 3 25.5
95 Bob 3 63.5
Reserves Relation
22 101 10/10/98
22 102 10/10/98
22 103 10/8/98
22 104 10/7/98
31 102 11/10/98
31 103 11/6/98
31 104 11/12/98
64 101 9/5/98
64 102 9/8/98
74 103 9/8/98
Boats Relation
Primary Keys:
Sailors: Sid
Reserves: Sid, day
Boats: Bid
Foreign Keys:
rating INT,
Age FLOAT
);
color VARCHAR(20)
);
Sid INT,
Bid INT,
day DATE
);
3) Insert the Values into Relations or Tables
DESC Sailors;
DESC Boats;
DESC reserves;
5) Display the contents of Sailors Relation, Reserves Relation and Boat Relation.(SELECT)
FROM Sailors;
8) Find all sailors with rating above 7.
G) Find the names of sailors who have reserved boat number 103
SELECT s.sname
FROM Sailo s
FROM reserves r
11) Find the names of sailors who have reserved a red boat.
FROM Sailors s
FROM Sailors s
13) Find the names of sailors who have reserved at least one boat.(NESTED QUERY USING
IN)
SELECT sname
FROM Sailors
WHERE Sid IN (
FROM reserves
);
14) Find the ages of sailors whose name begins and ends with B and has at least three
characters.
SELECT Age
FROM Sailors
15) Insert the Value of Sid=G5 in sailors Relations and write the output.
16) Insert the Value of Sid=100 and bid = 105 and day 15/10/G6 in Reserves Relations and
write the output.
17) Find the names of sailors who have reserved a red or a green boat
FROM Sailors s
18) Find the sids of all sailors who have reserved red boats but not green boats.
FROM reserves r1
SELECT r2.Sid
FROM reserves r2
JOIN Boats b2 ON r2.Bid = b2.Bid
);
1G) Find all sids of sailors who have rating of 10 or Reserved boat 104.
FROM Sailors s
WHERE s.rating = 10
OR s.Sid IN (
SELECT r.Sid
FROM reserves r
);
DROP, TRUNCATE, DELETE, UPDATE, RENAME COMMANDS
UPDATE Sailors
SET rating = 8
Age FLOAT,
UNIQUE (sname),
);
bname VARCHAR(50),
UNIQUE (bname)
);
Sid INT,
Bid INT,
);
25) Display the Relations or tables of above operations.
SHOW TABLES;
DESCRIBE Sailors;
DESCRIBE Boats;
DESCRIBE Reserves;
SHOW CREATE TABLE Sailors;