#PROBLEM STATEMENT
Notown Records has decided to store information
about musicians who perform on its albums. Each musician that records at Notown
has an SSN, a name, an address, and a phone number. No musician has more than
one phone. Each instrument used in songs recorded at Notown has a unique
identification number, a name (e.g., guitar, synthesizer, flute) and a musical
key (e.g., C, B-flat, E-flat). Each album recorded on the Notown label has a
unique identification number, a title, a copyright date and a format (e.g., CD
or MC). Each song recorded at Notown has a title and an author. Each musician
may play several instruments, and a given instrument may be played by several
musicians. Each album has a number of songs on it, but no song may appear on
more than one album. Each song is performed by one or more musicians, and a
musician may perform a number of songs. Each album has exactly one musician who
acts as its producer. A musician may produce several albums. Queries
a) List musician name, title of the song which he
has played, the album in which song has occulted.
b) List the details of songs which are performed by more than 3 musicians.
c) List the different instruments played by the
musicians and the average number of musicians who play the instrument.
d) Retrieve album title produced by the producer who
plays guitar as well as flute and has produced no of songs greater than the
average songs produced by all producers.
e) List the details of musicians who can play all
the instruments present.
...........................CREATE
TABLES.............................
create table projects
(
pno number,
sponsor varchar(15),
st_date number,
end_date number,
budget number,
primary
key(pno)
);
create table professor
(
prof_id number primary key,
name varchar(15),
age number(5),
rank varchar(10),
speciality varchar(15),
pno number references projects
);
create table students
(
usn varchar(5),
name varchar(15),
program varchar(15),
primary
key(usn)
);
create table stud_workson_proj
(
prof_id number references professor,
pno number references projects,
usn varchar(20) references students
);
create table prof_workson_proj
(
prof_id number references professor,
pno number references projects
);
...............................INSERT INTO
TABLE.........................
insert into projects
values('101','UGC','2006','2028','70000');
insert into projects values('102','UG','1992','2026','60000');
insert into projects
values('103','UG','2003','2024','50000');
insert into projects
values('104','COLL','2008','2022','000');
insert into projects
values('105','UFC','2010','2020','30000');
insert into projects values('106','ULC','2001','2018','20000');
insert into projects
values('107','UML','2000','2016','65000');
insert into projects
values('108','FLV','1999','2014','75000');
insert into projects
values('109','DOC','2006','2012','78000');
insert into projects values('110','UGC','2004','2010','85000');
insert into professor
values('201','Abhishek','20','1200','database mgt','101');
insert into professor
values('202','Hrishikesh','21','1201','database','102');
insert into professor
values('203','Tejraj','22','1202','D.S','101');
insert into professor
values('204','Kokitkar','23','1203','Unix','103');
insert into professor
values('205','Kotrappa','24','1204','mysql','104');
insert into professor
values('206','Govind','25','1205','Clang','105');
insert into professor values('207','Swaroopa','26','1206','cpp','106');
insert into professor
values('208','Venogopal','27','1207','java','102');
insert into professor
values('209','Mithari','28','1208','O.S','105');
insert into professor
values('210','Manoj','29','1209','system s/w','103');
insert into professor
values('211','Poonam','30','1300','visual basic','101');
insert into professor
values('212','Amol','31','1301','fco','106');
insert into professor
values('213','Raghvendra','32','1302','DMS','108');
insert into professor values('214','Narendra','33','1303','WEB','108');
insert into professor
values('215','Sonia','34','1304','computer n/w','105');
insert into students values('s01','Abhijeet','MCA');
insert into students values('s02','Abid','BCA');
insert into students values('s03','Akshata','BE');
insert into students values('s04','Ankita','MCA');
insert into students values('s05','Apurva','MCA');
insert into students values('s06','Anoop','MSC');
insert into students values('s07','Aparna','MS');
insert into students values('s08','Adavesh','MCA');
insert into students
values('s10','Rajnikanth','BBA');
insert into students values('s11','Amit','MBA');
insert into students values('s12','Soumya','MCA');
insert into students values('s13','Amita','MCA');
insert into students values('s14','Apeksha','MCA');
insert into students values('s15','Akshay','BE');
insert into students values('s16','Chetana','BE');
insert into students values('s17','Maya','MCA');
insert into students values('s18','dhanraj','ARCH');
insert into students values('s19','Anant','MCA');
insert into students values('s20','kiran','BE');
insert into stud_workson_proj
values('201','101','s01');
insert into stud_workson_proj
values('201','102','s02');
insert into stud_workson_proj
values('202','103','s03');
insert into stud_workson_proj
values('203','101','s01');
insert into stud_workson_proj
values('204','104','s01');
insert into stud_workson_proj
values('205','103','s03');
insert into stud_workson_proj
values('205','105','s04');
insert into stud_workson_proj
values('206','104','s05');
insert into stud_workson_proj
values('207','101','s06');
insert into stud_workson_proj
values('209','102','s04');
insert into stud_workson_proj
values('201','105','s03');
insert into stud_workson_proj
values('201','106','s05');
insert into stud_workson_proj
values('202','107','s07');
insert into stud_workson_proj
values('203','103','s05');
insert into stud_workson_proj
values('204','103','s05');
insert into stud_workson_proj
values('206','105','s04');
insert into stud_workson_proj
values('205','105','s06');
insert into stud_workson_proj
values('207','101','s08');
insert into stud_workson_proj
values('208','107','s14');
insert into stud_workson_proj
values('208','103','s11');
insert into stud_workson_proj
values('201','107','s11');
insert into stud_workson_proj
values('201','103','s11');
insert into stud_workson_proj
values('201','104','s11');
insert into stud_workson_proj
values('201','108','s11');
insert into stud_workson_proj
values('201','110','s11');
insert into prof_workson_proj values('201','101');
insert into prof_workson_proj values('202','101');
insert into prof_workson_proj values('203','101');
insert into prof_workson_proj values('204','102');
insert into prof_workson_proj values('205','103');
insert into prof_workson_proj values('206','103');
insert into prof_workson_proj values('207','102');
insert into prof_workson_proj values('208','108');
insert into prof_workson_proj values('209','108');
insert into prof_workson_proj values('210','102');
insert into prof_workson_proj values('211','104');
insert into prof_workson_proj values('212','101');
insert into prof_workson_proj values('215','106');
insert into prof_workson_proj values('214','106');
insert into prof_workson_proj values('215','108');
insert into prof_workson_proj values('204','108');
insert into prof_workson_proj values('205','104');
insert into prof_workson_proj values('206','108');
insert into prof_workson_proj values('203','109');
insert into prof_workson_proj values('206','110');
insert into prof_workson_proj values('207','101');
insert into prof_workson_proj values('201','109');
insert into prof_workson_proj values('201','102');
insert into prof_workson_proj values('201','103');
insert into prof_workson_proj values('201','104');
insert into prof_workson_proj values('201','105');
insert into prof_workson_proj values('201','106');
insert into prof_workson_proj values('201','107');
insert into prof_workson_proj values('201','108');
insert into prof_workson_proj values('201','110');
insert into prof_workson_proj values('202','102');
insert into prof_workson_proj values('202','103');
insert into prof_workson_proj values('202','104');
insert into prof_workson_proj values('202','105');
insert into prof_workson_proj values('202','106');
insert into prof_workson_proj values('202','107');
insert into prof_workson_proj values('202','108');
insert into prof_workson_proj values('202','109');
insert into prof_workson_proj values('202','110');
QUERIES:
1.
select p.name
from professor p, projects pr
where p.pno=pr.pno AND budget<100000;
NAME
--------------------
Abhishek
Hrishikesh
Tejraj
Kokitkar
Kotrappa
Govind
Swaroopa
Venogopal
Mithare
Manoj
Poonam
NAME
--------------------
Amol
Raghvendra
Narendra
Sonia
15 rows selected.
2.
select
s.name,p.name,a.sponsor
from students s, professor p, projects a,
stud_workson_proj w
where s.usn=w.usn AND p.prof_id=w.prof_id AND
a.pno=w.pno;
NAME
NAME SPONSOR
-------------------- -------------------- --------------------
Akhilesh
Abhishek UGC
Abid
Abhishek UG
Akshata
Hrishikesh UG
Akhilesh
Tejraj UGC
Akhilesh
Kokitkar COLL
Akshata
Kotrappa UG
Ankita
Kotrappa UFC
Apurva
Govind COLL
Anoop
Swaroopa UGC
Ankita
Mithare UG
Akshata
Abhishek UFC
Apurva
Abhishek ULC
Aparna
Hrishikesh UML
Apurva
Tejraj UG
Apurva
Kokitkar UG
Ankita
Govind UFC
Anoop Kotrappa UFC
Adavesh
Swaroopa UGC
Amit
Venogopal UG
Apeksha
Venogopal UML
20 rows selected.
3.
select
p.name, sum(budget)
from professor p, projects a
where p.pno=a.pno AND a.st_date>2000 AND
a.end_date=2018
group by p.name;
NAME
SUM(BUDGET)
-------------------- -----------
Amol 20000
Swaroopa 20000
4.
select p.name
from professor p, projects a
where p.pno=a.pno AND
BUDGET>(select avg(budget)
from projects);
NAME
--------------------
Abhishek
Hrishikesh
Tejraj
Venogopal
Poonam
Raghvendra
Narendra
7 rows selected.select *
5.
select p.name
from professor p
where p.prof_id in(select prof_id
from prof_workson_proj
group by prof_id
having count(*)=(select count(*)
from projects));
NAME
--------------------
Hrishikesh