Database Lab Program
Database Lab Program
DEPOSITOR(customer-name:string, accno:int)
BORROWER(customer-name:string, loan-number:int)
(i) Create the above tables by properly specifying the primary keys and the foreign keys
Branch
city varchar(10),
assets real
);
Account
balance real,
);
Cust
cstreet varchar(10),
city varchar(10)
);
Depositor
);
Loan
amt real,
);
Borrower
);
Branch
Account
Customer
Depositor
Loan
Borrower
(iii) Find all the customers who have at least two accounts at the Main branch.
select cname from account a,depositor d where a.accno=d.accno and bname='def' group by cname having
count(*)>1;
(iv) Find all the customers who have an account at all the branches located in a specific city.
select cname from cust c where not exists (select bname from branch where city='bang' minus select
bname from deposit or d,account a where d.accno=a.accno and d.cname=c.cname) and exists(select
bname from branch where city='bang');
(v) Demonstrate how you delete tuples in ACCOUNT relation at every branch locate
d in a specific city.
delete from account where bname in (select bname from branch where city='che');