Escolar Documentos
Profissional Documentos
Cultura Documentos
select
select
select
select
select
select
*
*
*
*
*
*
*
from
from
from
from
from
from
from
BOOK
BOOK_AUTHORS
publisher
BOOK_COPIES
BORROWER
BOOK_LOANS
BRANCH
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INTO
( 1,
INTO
( 2,
INTO
( 3,
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INTO book_copies(
( 'bookid1', 1,5
INTO book_copies(
( 'bookid2', 2,5
INTO book_copies(
( 'bookid3', 3,5
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
branch( branchid,branchname,address )
'branchname1','add1' ) ;
branch( branchid,branchname,address )
'branchname2','add2' ) ;
branch( branchid,branchname,address )
'branchname3','add3' ) ;
bookid,branchid,no_of_copies )
) ;
bookid,branchid,no_of_copies )
) ;
bookid,branchid,no_of_copies )
) ;
ASSIGNMENT-3 DATA
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INTO
( 1,
INTO
( 2,
INTO
( 3,
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
INSERT
branch( branchid,branchname,address )
'Sharpstown','add1' ) ;
branch( branchid,branchname,address )
'branchname2','add2' ) ;
branch( branchid,branchname,address )
'Central','add3' ) ;
)
) ;
)
)
)
)
)
)
)
)
)
)
)
INSERT
VALUES
INSERT
VALUES
INSERT
VALUES
1)
SELECT No_Of_Copies
FROM (BOOK NATURAL JOIN BOOK_COPIES ) NATURAL JOIN BRANCH
WHERE Title='The Lost Tribe' AND BranchName='Sharpstown';
2)
SELECT BranchName, No_Of_Copies
FROM (BOOK NATURAL JOIN BOOK_COPIES ) NATURAL JOIN LIBRARY_BRANCH
WHERE Title='The Lost Tribe';
3)
select cardno,name
from borrower
where cardno not in (select cardno from book_loans);
4)
select co.title,bor.name,bor.address
from book_loans b, branch br, book bo, borrower bor
where b.BRANCHID=br.BRANCHID and b.bookid=bo.bookid and b.cardno=bor.cardno
and br.branchname='Sharpstown' and b.duedate=sysdate;
5)
select br.branchname,count(bo.cardno)
from branch br, book_loans bo
where br.branchid=bo.branchid
group by br.branchname;
6)
select bor.name,bor.address,count(*)
from borrower bor, book_loans bol
where bor.cardno=bol.cardno
group by bor.cardno, bor.name,bor.address
having count(*) >=5;
7)
select bo.title,bc.NO_OF_COPIES
from book bo, book_copies bc, branch br, book_authors ba
where bo.bookid=bc.bookid and bo.bookid=ba.bookid and bc.branchid=br.branchid
and ba.authorname='Stephen King' and br.branchname='Central';