gs gs114 Practical Questions Subjective Solved Past Paper No.1

gs gs114 Relational Database Management System Solved Past Papers

Solved Past Papers

This subjective solved past paper is related to book/course code gs gs114 Relational Database Management System which belongs to gs organization. We have 1 past papers available related to the book/course Relational Database Management System. This past paper has a total of 38 subjective questions belongs to topic Practical Questions to get prepared. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to get prepared for exams by learning subjective questions online on NVAEducatio.

NVAEducation also facilitates users to download these solved past papers with an affordable prices. However, users are not enforced to pay for money, rather they can use credits to buy such stuff on NVAEducation. Users can earn credits for doing some little tasks and then you will be able to use that credits to buy solved past papers on NVAEducation.

Question 1: Create a Bank Database schema with the following relations and select an appropriate primary key.
account(account_number, branch_name, balance)
branch (branch_name, branch_city, assets)
customer (customer_name customer_street, customer_city)
loan (loan_number, branch_name, amount)
depositor((customer_name, account_number)
borrower(customer_name, loan_number)
Answer:
create table account (account_number varchar(15) not null unique,
branch_name varchar(15) not null,
balance number not null,
primary key(account_number));

create table branch
(branch_name varchar(15) not null unique,
branch_city varchar(15) not null,
assets number not null,
primary key(branch_name));

create table customer
(customer_name varchar(15) not null unique,
customer_street varchar(12) not null,
customer_city varchar(15) not null,
primary key(customer_name));

create table loan
(loan_number varchar(15) not null unique,
branch_name varchar(15) not null,
amount number not null,
primary key(loan_number));

create table depositor
(customer_name varchar(15) not null,
account_number varchar(15) not null,
primary key(customer_name, account_number),
foreign key(account_number) references account(account_number),
foreign key(customer_name) references customer(customer_name));

create table borrower
(customer_name varchar(15) not null,
loan_number varchar(15) not null,
primary key(customer_name, loan_number),
foreign key(customer_name) references customer(customer_name),
foreign key(loan_number) references loan(loan_number));

Question 2: List all branch names and their assests
Answer:
select branch_name, assets from branch;
Question 3: List all accounts of Brooklyn branch
Answer:
select account_number from account natural join branch where branch_city=’Brooklyn’;
Question 4: List all loans with amount > 1000.
Answer:
select * from loan where amount>1000;
Question 5: List all accounts of Perryridge branch with balance < 1000.
Answer:
select account_number from account where branch_name=’Perryridge’ and balance < 1000;
Question 6: List Numbers of accounts with balances between 700 and 900
Answer:
select count(account_number) from account where balance > 700 and balance < 900;
Question 7: Change the assests of Perryridge branch to 340000000.
Answer:
update branch set assets = 340000000 where branch_name=’Perryridge’;
Question 8: Transfer the accounts and loans of Perryridge branch to Downtown branch.
Answer:
update account set branch_name=’Downtown’ where branch_name=’Perryridge’; update loan set branch_name=’Downtown’ where branch_name = ‘Perryridge’;
Question 9: Transfer Rs. 100 from account A-101 to A-215.
Answer:
update account set balance = case
when account_number=’A-101′ then balance-100
when account_number=’A-215′ then balance+100
else balance
end;
Question 10: Delete the branch Perryridge.
Answer:
delete from account where branch_name=’Perryridge’; delete from branch where branch_name=’Perryridge’;
delete from loan where branch_name=’Perryridge’;
Question 11: Waive off all the loans with amount < 1000.
Answer:
delete from borrower where loan_number in (select loan_number from loan where amount<1000);
delete from loan where amount<1000;
Question 12: Delete the accounts and loans of Downtown branch.
Answer:
delete from depositor where account_number IN (select account_number from account where branch_name=’Downtown’);

delete from account where branch_name=’Downtown’;

delete from borrower where loan_number IN
(select loan_number from loan where branch_name=’Downtown’);

delete from loan where branch_name=’Downtown’;

Question 13: Add a column phoneNo to customer table.
Answer:
alter table customer add phoneNo numeric(10);
Question 14: Change the size of the branch_city to varchar(20).
Answer:
ALTER TABLE branch ALTER COLUMN branch_city type varchar(20);
Question 15: Drop the column phoneNo from customer table.
Answer:
ALTER TABLE customer drop phoneNo;
Question 16: For all customers who have a loan from the bank, find their names, loan numbers, and loan amount.
Answer:
select customer_name,loan_number,amount from borrower natural join loan;
Question 17: Find the customer names, loan numbers, and loan amounts, for all loans at the Perryridge branch.
Answer:
select customer_name,loan_number,amount from depositor natural join loan where loan.branch_name=’Perryridge’;
Question 19: Find the names of all branches that have assets greater than atleast one branch located in Brooklyn.
Answer:
select branch_name from branch where assets > (select min(assets) from branch where branch_city = ‘Brooklyn’);
Question 20: Find the names of all customers whose street address includes the substring ‘Main’.
Answer:
select customer_name from customer where customer_street like ‘%Main%’;
Question 21: List loan data, ordered by decreasing amounts, then increasing loan numbers.
Answer:
select * from loan order by amount desc, loan_number asc;
Question 22: Find all the bank customers having a loan, an account, or both at the bank.
Answer:
select customer_name from depositor union all
select customer_name from borrower;
Question 23: Find all the bank customers having both a loan and an account at the bank
Answer:
select customer_name from depositor intersect all
select customer_name from borrower;
Question 24: Find all customers who have an account but no loan at the bank.
Answer:
select avg(balance) from account where branch_name=’Perryridge’;
Question 25: Find the average account balance at each branch.
Answer:
select avg(balance),branch_name from account natural join depositor
group by branch_name;
Question 26: Find the number of depositors for each branch (Use distinct).
Answer:
select count(Distinct customer_name),branch_name from account natural join depositor
group by branch_name;
Question 27: Find those branches where the average accounts balance is more than Rs. 1200.
Answer:
select branch_name from account group by branch_name
having avg(balance)>1200
Question 28: Find the number of branches of the bank.
Answer:
select count(distinct branch_name) from branch;
Question 30: Find all the customers who have both a loan and an account at the Perryridge branch
Answer:
select customer_name from loan natural join borrower where branch_name = ‘Perryridge’ and
customer_name in
(select customer_name from account natural join depositor
where branch_name = ‘Perryridge’);
Question 31: Find all customers who do have a loan at the bank, but do not have an account at the bank.
Answer:
select customer_name from loan natural join borrower where customer_name not in
(select customer_name from account natural join depositor);
Question 32: Select the names of customers who have a loan at the bank, and whose names are neither Smith nor Jones
Answer:
select customer_name from loan natural join borrower where branch_name = ‘Perryridge’ and customer_name not in
(‘Smith’, ‘Jones’);
Question 33: Find the names of all branches that have assets greater than those of at least one branch located in Brooklyn.
Answer:
select branch_name from branch where assets > some(select assets from branch
where branch_city = ‘Brooklyn’);
Question 34: Find the names of all branches that have an asset value greater than that of each branch in Brooklyn.
Answer:
select branch_name from branch where assets > some(select assets from branch
where branch_city = ‘Brooklyn’);
Question 35: Find all customers who have both an account and a loan at the bank
Answer:
select distinct customer_name from borrower as b1 where exists (select customer_name from depositor as b2
where b1.customer_name = b2.customer_name);
Question 36: Find all customers who have an account at all the branches located in Brooklyn.
Answer:
select customer_name from account as b1 natural join depositor
where exists (select * from branch
where b1.branch_name = ‘Downtown’
and b1.branch_name=’Brighton’);
Question 37: Find all customers who have at most one account at the Perryridge branch
Answer:
select customer_name from account natural join depositor where branch_name = ‘Perryridge’ group by customer_name
having count(account_number)<=1;
Question 38: Find all customers who have at least two accounts at the perryridge branch
Answer:
select avg(balance),branch_name from account where balance > 1200 group by branch_name;

Solved Past Papers of gs114 Relational Database Management System

Other DB related subjective solved past papers

Other categories of gs Solved Past Papers

Other organizations

Theme Customizer

Gaussian Texture



Gradient Background