0% found this document useful (0 votes)
8 views

week-4

Uploaded by

karan20067852
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

week-4

Uploaded by

karan20067852
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 10

COMPUTER SCIENCE AND

ARTIFICIAL INTELLIGENCE
DATABASE MANAGEMENT SYSTEMS
Week-4 Assignment
Name : M.Aravind
Hall ticket no : 2203A51020
Section : A
Batch - 1
------------------------------------------------------------------------------------------------------------
Create table
1. sailor (sl_id, slname, ratings, age)
2. boats(bt_id, btname, quantity, colour)
3. reserves(sl_id, bt_id, day)

Command: create table sailor1020(sl_id int primary key,sname char(10) not null,
age int not null, Rating int check(Rating >=1 And Rating <=10));

Command: desc sailor1020;

Command: create table boat1020(bt_id int primary key,bt_name char(10)


unique,b_color char(10));

Command: desc boat1020;


Command: create table reserve1020(sl_id int,bt_id int,day date,primary
key(sl_id,bt_id,day),foreign key(sl_id) references sailor1020(sl_id),foreign
key(bt_id) references boat1020(bt_id));

Command: desc reserve1020;

Create the above tables with appropiate data types, domain


constraints and identify the primary and foreign keys of the same.
Insert atleast 10 rows into each table.

Command: select * from sailor1020;


Command: select * from boat1020;
Command: select * from reserve1020;
Mr. Sandeep is the supervisor of an online Ferry Ticket Management
system and is willing to know the following details of his enterprise:
List (IDs) of black color boats that were reserved by people whose
name starts with ‘S’

Command: Select s.sl_id,s.sname from sailor1020 s,boat1020 b, reserve1020 r where


s.sl_id = r.sl_id And b.bt_id = r.bt_id And b.b_color = 'black' And s.sname like 'r%';
The youngest sailor whose rating is ‘10’ has to be felicitated by the
enterprise, Is there such an eligible person for felicitation, if yes,
identify the sailor

Command: select min(s.age) from sailor1020 s where s.rating=10;

The average age of all the sailors who have reserved a red boat
Command: select avg(s.age) from sailor1020 s, reserve1020 r,boat1020 b where
s.sl_id = r.sl_id and b.bt_id = r.bt_id and b.b_color = 'red';
A boat 501 has been cancelled on a particular date and hence the
enterprise has decided to cancel all the reservations for that
particular boat on that day. Help Sandeep find out if there are sailors
who have reserved that boat on ’03-MAR-2024’,

Command: select s.sname from sailor1020 s, reserve1020 r,boat1020 b where s.sl_id


= r.sl_id and b.bt_id = r.bt_id and r.day = '24-feb-24';

Command: select * from sailor1020 s where s.sname='bipin';

Mr. Sandeep wants to know how many sailors have reserved the
boats in the last week on each day from 06th Feb to 12th Feb 2024

Command: SELECT count(s.sl_id) FROM sailor1020 s, reserve1020 r,boat1020 b


where s.sl_id = r.sl_id and b.bt_id = r.bt_id and day >= '14-feb-24' and day <= '24-
feb-24';

Command: SELECT * FROM sailor1020 s, reserve1020 r,boat1020 b where s.sl_id


= r.sl_id and b.bt_id = r.bt_id and r.day = '19-feb-24';
Command: SELECT * FROM sailor1020 s, reserve1020 r,boat1020 b where s.sl_id
= r.sl_id and b.bt_id = r.bt_id and r.day = '22-feb-24';

Command: SELECT * FROM sailor1020 s, reserve1020 r,boat1020 b where s.sl_id


= r.sl_id and b.bt_id = r.bt_id and r.day = '23-feb-24';

Command: SELECT * FROM sailor1020 s, reserve1020 r,boat1020 b where s.sl_id


= r.sl_id and b.bt_id = r.bt_id and r.day = '24-feb-24';

You might also like