Prog 5
Prog 5
BRANCH(branch-name:string,branch-city:string,assets:real)
ACCOUNT(accno:int,branch-name:string,balance:real)
DEPOSITER(customer-name:string,accno:int)
CUSTOMER(customer-name:string,customer-street:string,customer-city:string)
LOAN(loan-number:int,branch-name:string,amount:real)
BORROWER(customer-name:string,loan-number:int)
1)create the above tables by properly specifying the primary keys and the foreign keys
2)enter at least five tupels for each relation
3)find all the customers who have at least two accounts at the main branch.
4)find all the customers who have an account at all the branches located in a specific city.
5)demonstrate how you delete all account tuples at every branch located in a specific city.
Answer…
create table branch5(branchname varchar(20),
branchcity varchar(20),
assets real,
constraint pkey1 primary key(branchname));
1
create table customer5(customername varchar(20),
customerstreet varchar(20),
customercity varchar(20),
constraint pkey3 primary key(customername));
2
insert into borrower5 values('Ramu',1111);
insert into borrower5 values('Kumar',2222);
insert into borrower5 values('John',3333);
insert into borrower5 values('Mike',4444);
insert into borrower5 values('Sachin',5555);
a>find all the customers who have an account at all the branches located in a specific
city.
SELECT C5.customername
FROM customer5 C5,depositor5 D5,account5 A5
WHERE C5.customername=D5.customername AND D5.accno=A5.accno AND
A5.branchname='Gandhinagar'
group by C5.customername HAVING COUNT(A5.accno)>=2;
b>find all the customers who have atleast two accounts at the main branch.
c>demonstrate how you delete all account tuples at every branch located in a specific
city.