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

'Priya' 'Siya' 'Tiksha' 'Neha' 'Saily': Day Day

The document contains SQL statements that create three tables: sailors, boats, and reserves. The sailors table stores sailor details, the boats table stores boat details, and the reserves table establishes relationships between sailors and boats for specific days using foreign keys. Sample data is inserted into each table. Two select statements at the end query the sailors and reserves tables.

Uploaded by

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

'Priya' 'Siya' 'Tiksha' 'Neha' 'Saily': Day Day

The document contains SQL statements that create three tables: sailors, boats, and reserves. The sailors table stores sailor details, the boats table stores boat details, and the reserves table establishes relationships between sailors and boats for specific days using foreign keys. Sample data is inserted into each table. Two select statements at the end query the sailors and reserves tables.

Uploaded by

tansen1234
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

create table sailors(sid int primary key,s_name varchar(100),rating int,age

int)
insert into sailors values(1001,'Priya',6,32)
insert into sailors values(1002,'Siya',8,30)
insert into sailors values(1003,'Tiksha',4,27)
insert into sailors values(1004,'Neha',2,35)
insert into sailors values(1005,'saily',3,33)
select * from sailors


create table boats(b_id int primary key,b_name varchar(100),color
varchar(100))
insert into boats values(131,'Paris','blue')
insert into boats values(132,'Russia','yellow')
insert into boats values(133,'India','orange')
insert into boats values(134,'America','red')
insert into boats values(135,'africa','green')
select * from boats


create table reserves(sid int references sailors(sid),b_id int references
boats(b_id),day varchar(100),primary key(sid,b_id,day))
insert into reserves values(1001,131,'Sunday')
insert into reserves values(1002,132,'Monday')
insert into reserves values(1003,133,'Tuesday')
insert into reserves values(1004,134,'Wednesday')
insert into reserves values(1005,135,'Thursday')
select * from reserve
OUTPUT:

select s_name,age from sailors
output:


select s_name
from sailors,reserves
where reserves.sid=sailors.sid and b_id=133

You might also like