Dbms Lab
Dbms Lab
Dbms Lab
create table booklending(dateout date, duedate date, book_id references book(book_id) on delete
cascade, branch_id references lib_branch(branch_id) on delete cascade, cardno references
card(cardno) on delete cascade, primary key(book_id, branch_id, cardno));
create table publisher(name varchar(20) primary key, phone int, address varchar(20));
QUERY
select b.book_id,b.title,b.publisher_name,ba.author_name,bc.noofcopies ,bc.branch_name
from book b,book_author ba,book_copies bc,lib_branch lb
where b.book_id=ba.book_id and
b.book_id=bc.book_id and
bc.branch_id=lb.branch_id;
select cardno
from booklending
where Date_out between '2017-01-01' AND '2017-06-30'
Group by cardno
Having count(*)>3;
QUERY
select count(customer_id)
from customer
where grade > (select Avg(grade)
from customer
where city='Bangalore');
select s.name,count(customer_id)
from salesman s,customer c
where s.salesman_id=c.salesman_id
Group by name
Having count(customer_id)>1;
(select name from salesman S,customer C where S.salesman_id=C.salesman_id and S.city=C.city)
UNION
(select name
from salesman S,customer C
where S.salesman_id NOT IN(select S.salesman_id from salesman S,customer C where
S.salesman_id=C.salesman_id and S.city=C.city));