0% found this document useful (0 votes)
25 views2 pages

Sailor

Uploaded by

Tejaswini AS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Sailor

Uploaded by

Tejaswini AS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

create database sailors;

use sailors;

CREATE TABLE SAILOR(

Sid INT PRIMARY KEY,

Sname VARCHAR(50),

Rating INT,

Age real);

DESC SAILOR;

CREATE TABLE BOATS (

Bid INT PRIMARY KEY,

Bname VARCHAR(30),

Color VARCHAR(30));

CREATE TABLE RESERVES (

sid INT,

Bid INT,

Day date,

primary key(sid,bid,Day),

FOREIGN KEY(Bid) REFERENCES BOATS(Bid),

FOREIGN KEY(sid) REFERENCES SAILOR(sid))

insert into sailor values(1,"Ajay T",4,34);

insert into sailor values(2,"Ram",5,27);

insert into sailor values(3,"Dev",7,39);

insert into sailor values(4,"Raj",10,22);

insert into sailor values(5,"Raju",9,23);

insert into boats values(101,"AA","Red");

insert into boats values(102,"BB","Grey");


insert into boats values(103,"CC","Yellow");

insert into boats values(104,"DD","Blue");

insert into boats values(105,"EE","White");

insert into reserves values(1,101,"2021-10-10");

insert into reserves values(2,102,"2021-11-10");

insert into reserves values(3,103,"2021-12-10");

insert into reserves values(4,104,"2021-10-15");

insert into reserves values(5,105,"2021-11-14");

SELECT * FROM SAILOR;

SELECT * FROM BOATS;

SELECT * FROM RESERVES;

select Sid, Sname from Sailor where rating>7 ;

select sname from sailor s join reserves r on s.sid=r.sid where bid=103;

select s.sname from sailor s join reserves r on s.sid=r.sid join boats b on r.bid=b.bid where b.color='red';

select distinct s.sname from sailor s join reserves r on s.sid=r.sid join boats b on r.bid=b.bid where b.color
IN ('red','green');

You might also like