Академический Документы
Профессиональный Документы
Культура Документы
enroll
insert into enroll values('cs42',1,6,98);
insert into enroll values('cs48',2,6,97);
insert into enroll values('ec26',5,5,50);
insert into enroll values('is48',3,7,90);
insert into enroll values('ee37',4,4,80);
insert into enroll values('cs48',1,6,35);
text
insert into text values(101,'let us c','lpe','fahad');
insert into text values(102,'c++','abc','mujeeb');
insert into text values(103,'oracle','def','othman');
insert into text values(104,'.net','abc','naushad');
insert into text values(105,'j2ee','pearson','mikhil');
bad
insert into bad values(1,6,101);
insert into bad values(2,6,103);
insert into bad values(3,5,102);
insert into bad values(4,4,104);
insert into bad values(5,7,105);
insert into bad values(5,3,104);
insert into bad values(5,4,103);
3.Demonstrate how you add a new text book to the database and make this book be
adopted by some department.
insert into text values(106,'JAVA','pearson','Avril');
insert into bad values(2,7,106);
4. Produce a list of text books( include course # ,book_isbn,book-title) in the
alphabetical order for courses offered by the cs department that use more than 2
books.
SELECT s.cno,t.title,b.isbn
FROM course s,bad b,text t
where s.cno=b.cno
AND b.isbn=t.isbn
AND s.dept='computer'
AND b.cno in (select b.cno
from bad b,course s
where b.cno=s.cno
group by b.cno
having count(*)>2)
order by t.title;
5.. List any department that has all its adopted books published by specific pub
lisher.
select distinct C.dept
from course C, bad A, text T
where C.cno =A.cno and A.isbn=T.isbn and not exists
((select Y.isbn
from course X,bad Y
where X.cno =Y.cno and X.dept=C.dept)
MINUS
(select isbn from text where publisher='abc'));