Problem title:
Consider the banking database bank consisting of the following tables where
the primary keys are underlined.
branch (branch_name,branch_city,assest)
customer(customer_name,customer_street,customer_city)
loan(loan_number,branch_name,amount)
borrower(customer_name,loan_number)
account(account_number,branch_name,balance)
depositor(customer_name,account_number)
Write down the SQL, expressions for the following queries:
a) Find the name and loan number of all customer who have a loan from the
bank.
b) Find the number of depositor for each branch.
c) Add and record in the database using a form.
d) Display your result a query on a report.
Database name:bank
Data-definition language (DDL):
CREATE TABLE account (
account_number varchar (255) NOT NULL,
branch_name varchar(255) NOT NULL,
balance decimal (10,0) NOT NULL,
PRIMARY KEY (account_number));
CREATE TABLE borrower(
customer_name varchar(255) NOT NULL,
loan_number varchar(255) NOT NULL,
PRIMARY KEY (customer_name, loan_number));
CREATE TABLE branch (
branch_name varchar (255) NOT NULL,
branch_city varchar (255) NOT NULL,
assets decimal (10,0) NOT NULL,
PRIMARY KEY (branch_name));
CREATE TABLE customer (
customer_name varchar (255) NOT NULL,
customer-city varchar (255) NOT NULL,
customer_street varchar (255) NOT NULL,
PRIMARY KEY (customer_name));
CREATE TABLE depositor (
customer_name
varchar (255) NOT NULL,
account_number varchar (255) NOT NULL,
PRIMARY KEY (customer_name , account_number));
CREATE TABLE loan (
loan_number varchar (255) NOT NULL,
branch_name varchar (255) NOT NULL,
amount decimal (10,0) NOT NULL,
PRIMARY KEY (loan_number));
Query:
a.
SELECT
FROM
borrower;
Problem Number: 06
Problem Title:
Consider the following company database consisting of the tables where the
primary keys are underlined.
lives(person_name, street, city)
works (person_name,company_name, salary)
Query:
a) UPDATE lives set city='dhanmondi'
WHERE person_name='Rahim';
b) SELECTCOUNT(*) AS Tuples
FROM works w,location l
WHEREw.company_name=l. company_name;
c) <html>
<body>
<form action="" method="post">
Person Name:<input type="text" name="personname"/>
Street: <input type="text" name="street"/>
City:<input type="text" name="city"/>
<input type="submit"/>
</form>
</body>
</html>
<?php
if( isset($_POST['prsonname']) && isset($_POST['street']) &&
isset($_POST['city'])){
$conn = oci_connect('system', 'root123', '//localhost/orcl');
// Check connection
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['connection not established'],
ENT_QUOTES), E_USER_ERROR);
}
$sql="INSERT INTO lives(prson_name, street, city)VALUES
('$_POST[personname]','$_POST[street]','$_POST[city]')";
$stid = oci_parse($conn,$sql);
oci_execute($stid);
echo "1 record added";
}
?>