0% found this document useful (1 vote)
278 views

Account Management System: Assignment 4

The document provides the schema and sample data to create tables for an account management system, including customers, branches, accounts, transactions, and loans. It then lists 7 requirements for writing SQL queries on the database, such as updating account balances, displaying customer information by date of birth or city, and showing aggregate data about accounts, transactions, and loans.

Uploaded by

MAHESH V
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
278 views

Account Management System: Assignment 4

The document provides the schema and sample data to create tables for an account management system, including customers, branches, accounts, transactions, and loans. It then lists 7 requirements for writing SQL queries on the database, such as updating account balances, displaying customer information by date of birth or city, and showing aggregate data about accounts, transactions, and loans.

Uploaded by

MAHESH V
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

ASSIGNMENT 4:

ACCOUNT MANAGEMENT SYSTEM

Prerequisite: Create the basic structure using DDL and DML statement as shown in exercise:
(CREATE TABLE STRUCTURE WITH GIVEN NAME_ )

Eg: customer_ yourname

CREATE TABLE customer

CUST_ID VARCHAR(6),

FIRST_NAME VARCHAR(30),

MID_NAME VARCHAR(30),

LAST_NAME VARCHAR(30),

CITY VARCHAR(15),

MOBILENO VARCHAR(10),

OCCUPATION VARCHAR(10),

CUST_DOB DATE,

CONSTRAINT customer_custid_pk PRIMARY KEY(CUST_ID)

);

CREATE TABLE branch

BRANCH_ID VARCHAR(6),

BRANCH_NAME VARCHAR(30),

BRANCH_CITY VARCHAR(30),

CONSTRAINT branch_bid_pk PRIMARY KEY(BRANCH_ID)

);

CREATE TABLE account


(

AC_NUMBER VARCHAR(6),

CUST_ID VARCHAR(6),

BRANCH_ID VARCHAR(6),

OPEN_BALANCE NUMBER,

AC_OPEN_DATE DATE,

AC_TYPE VARCHAR(10),

AC_STATUS VARCHAR(10),

CONSTRAINT account_acnumber_pk PRIMARY KEY(AC_NUMBER),

CONSTRAINT account_custid_fk FOREIGN KEY(CUST_ID) REFERENCES customer(CUST_ID),

CONSTRAINT account_bid_fk FOREIGN KEY(BRANCH_ID) REFERENCES branch(BRANCH_ID)

);

CREATE TABLE TRAN_DETAILS

TRAN_NUMBER VARCHAR(6),

AC_NUMBER VARCHAR(6),

TRAN_DATE DATE,

MIDIUM_OF_TRAN VARCHAR(20),

TRAN_TYPE VARCHAR(20),

TRAN_AMOUNT NUMBER,

CONSTRAINT trandetails_tnumber_pk PRIMARY KEY(TRAN_NUMBER),

CONSTRAINT trandetails_acnumber_fk FOREIGN KEY(AC_NUMBER) REFERENCES account(AC_NUMBER)

);
CREATE TABLE LOAN

CUST_ID VARCHAR(6),

BRANCH_ID VARCHAR(6),

LOAN_AMOUNT NUMBER,

CONSTRAINT loan_customer_custid_bid_pk PRIMARY KEY(CUST_ID,BRANCH_ID),

CONSTRAINT loan_custid_fk FOREIGN KEY(custid) REFERENCES customer(CUST_ID),

CONSTRAINT loan_bid_fk FOREIGN KEY(BRANCH_ID) REFERENCES branch(BRANCH_ID)

);

DML STATEMENTS FOR THE SYSTEM:

--Records for the bank customers

INSERT INTO customer


VALUES('C00001','Ramesh','Chandra','Sharma','Delhi','9543198345','Service',to_date('1976-12-06','YYYY-
MM-DD'));

INSERT INTO customer


VALUES('C00002','Avinash','Sunder','Minha','Delhi','9876532109','Service',to_date('1974-10-16','YYYY-
MM-DD'));

INSERT INTO customer


VALUES('C00003','Rahul',null,'Rastogi','Delhi','9765178901','Student',to_date('1981-09-26','YYYY-MM-
DD'));

INSERT INTO customer


VALUES('C00004','Parul',null,'Gandhi','Delhi','9876532109','Housewife',to_date('1976-11-03','YYYY-MM-
DD'));

INSERT INTO customer


VALUES('C00005','Naveen','Chandra','Aedekar','Mumbai','8976523190','Service',to_date('1976-09-
19','YYYY-MM-DD'));

INSERT INTO customer


VALUES('C00006','Chitresh',null,'Barwe','Mumbai','7651298321','Student',to_date('1992-11-06','YYYY-
MM-DD'));
INSERT INTO customer
VALUES('C00007','Amit','Kumar','Borkar','Mumbai','9875189761','Student',to_date('1981-09-06','YYYY-
MM-DD'));

INSERT INTO customer


VALUES('C00008','Nisha',null,'Damle','Mumbai','7954198761','Service',to_date('1975-12-03','YYYY-MM-
DD'));

INSERT INTO customer


VALUES('C00009','Abhishek',null,'Dutta','Kolkata','9856198761','Service',to_date('1973-05-22','YYYY-
MM-DD'));

INSERT INTO customer


VALUES('C00010','Shankar',null,'Nair','Chennai','8765489076','Service',to_date('1976-07-12','YYYY-MM-
DD'));

--Records for the bank branches

INSERT INTO branch VALUES('B00001','Asaf ali road','Delhi');

INSERT INTO branch VALUES('B00002','New delhi main branch','Delhi');

INSERT INTO branch VALUES('B00003','Delhi cantt','Delhi');

INSERT INTO branch VALUES('B00004','Jasola','Delhi');

INSERT INTO branch VALUES('B00005','Mahim','Mumbai');

INSERT INTO branch VALUES('B00006','Vile parle','Mumbai');

INSERT INTO branch VALUES('B00007','Mandvi','Mumbai');

INSERT INTO branch VALUES('B00008','Jadavpur','Kolkata');

INSERT INTO branch VALUES('B00009','Kodambakkam','Chennai');

--Records for account master

INSERT INTO account VALUES('A00001','C00001','B00001',1000,to_date('2012-12-15','YYYY-MM-


DD'),'Saving','Active');

INSERT INTO account VALUES('A00002','C00002','B00001',1000,to_date('2012-06-12','YYYY-MM-


DD'),'Saving','Active');
INSERT INTO account VALUES('A00003','C00003','B00002',1000,to_date('2012-05-17','YYYY-MM-
DD'),'Saving','Active');

INSERT INTO account VALUES('A00004','C00002','B00005',1000,to_date('2013-01-27','YYYY-MM-


DD'),'Saving','Active');

INSERT INTO account VALUES('A00005','C00006','B00006',1000,to_date('2012-12-17','YYYY-MM-


DD'),'Saving','Active');

INSERT INTO account VALUES('A00006','C00007','B00007',1000,to_date('2010-08-12','YYYY-MM-


DD'),'Saving','Suspended');

INSERT INTO account VALUES('A00007','C00007','B00001',1000,to_date('2012-10-02','YYYY-MM-


DD'),'Saving','Active');

INSERT INTO account VALUES('A00008','C00001','B00003',1000,to_date('2009-11-09','YYYY-MM-


DD'),'Saving','Terminated');

INSERT INTO account VALUES('A00009','C00003','B00007',1000,to_date('2008-11-30','YYYY-MM-


DD'),'Saving','Terminated');

INSERT INTO account VALUES('A00010','C00004','B00002',1000,to_date('2013-03-01','YYYY-MM-


DD'),'Saving','Active');

--Records for transaction details

INSERT INTO TRAN_DETAILS VALUES('T00001','A00001',to_date('2013-01-01','YYYY-MM-


DD'),'Cheque','Deposit',2000);

INSERT INTO TRAN_DETAILS VALUES('T00002','A00001',to_date('2013-02-01','YYYY-MM-


DD'),'Cash','Withdrawal',1000);

INSERT INTO TRAN_DETAILS VALUES('T00003','A00002',to_date('2013-01-01','YYYY-MM-


DD'),'Cash','Deposit',2000);

INSERT INTO TRAN_DETAILS VALUES('T00004','A00002',to_date('2013-02-01','YYYY-MM-


DD'),'Cash','Deposit',3000);

INSERT INTO TRAN_DETAILS VALUES('T00005','A00007',to_date('2013-01-11','YYYY-MM-


DD'),'Cash','Deposit',7000);

INSERT INTO TRAN_DETAILS VALUES('T00006','A00007',to_date('2013-01-13','YYYY-MM-


DD'),'Cash','Deposit',9000);

INSERT INTO TRAN_DETAILS VALUES('T00007','A00001',to_date('2013-03-13','YYYY-MM-


DD'),'Cash','Deposit',4000);
INSERT INTO TRAN_DETAILS VALUES('T00008','A00001',to_date('2013-03-14','YYYY-MM-
DD'),'Cheque','Deposit',3000);

INSERT INTO TRAN_DETAILS VALUES('T00009','A00001',to_date('2013-03-21','YYYY-MM-


DD'),'Cash','Withdrawal',9000);

INSERT INTO TRAN_DETAILS VALUES('T00010','A00001',to_date('2013-03-22','YYYY-MM-


DD'),'Cash','Withdrawal',2000);

INSERT INTO TRAN_DETAILS VALUES('T00011','A00002',to_date('2013-03-25','YYYY-MM-


DD'),'Cash','Withdrawal',7000);

INSERT INTO TRAN_DETAILS VALUES('T00012','A00007',to_date('2013-03-26','YYYY-MM-


DD'),'Cash','Withdrawal',2000);

--Records for loan details

INSERT INTO loan VALUES('C00001','B00001',100000);

INSERT INTO loan VALUES('C00002','B00002',200000);

INSERT INTO loan VALUES('C00009','B00008',400000);

INSERT INTO loan VALUES('C00010','B00009',500000);

INSERT INTO loan VALUES('C00001','B00003',600000);

INSERT INTO loan VALUES('C00002','B00001',600000);

Requirement 1: Update Customer Account Balance


1. Update the account_balance in Account table
2. For account type saving
3. Increase the account_balance by 500 for all the account with account type saving
Requirement 2: Query to display customer information based on date of birth month
a. Display customer first_name and date_of_birth
b. Display date_of_birth in format of “DD-MON-YYYY”
c. Customer whose date of birth month is November or September

Expected Result:

FNAME DATE OF BIRT


------------------------------ ------------
Rahul 26- SEP-1981
Parul 03- NOV-1976
Naveen 19-SEP-1976
Chitresh 06-NOV-1992
Amit 06-SEP-1981

Requirement 3: Query to display city name and number of customer


In that city
a. Display city name and number of customer in that city
b. Display only those cities having prefix ‘p’ or ‘c’ (not a case sensitive )
Expected Result:

CITY NUMBER OF CITY

--------------- ---------------

pune 1

Chennai 1

Requirement 4: Query to Display Customer name in given format along with loan amount
a. Display customer name first name , middle name ,last name as shown in expected
result
b. If middle name is not present then print ‘—’ in place of middle name

Expected Result:

CUSTOMER NAME LOAN AMOUNT


RameshChandraSharma 600000
AvinashSunderMinha 600000
AvinashSunderMinha 200000
Abhishek--Dutta 400000
Shankar--Nair 500000

Requirement 5: Query to Display Customer Name and the account details in given format
a. Display customer first name , type of transaction and number of transaction
Expected Result:
Name Transaction Type Number OF Transaction
Avinash Withdrawal 1
Avinash Deposit 2
Ramesh Withdrawal 3
Ramesh Deposit 3
Amit Withdrawal 1
Amit Deposit 2

Requirement 6: Query to display branch name and total number of account present in that
branch

Expected Result:

Branch Name Number Of Accounts


New Delhi main branch 2

Mandvi 2

Delhi cant 1
Mahim 1

Asaf ali road 3

Vile parle 1

Requirement 7: Query to display customer information who are having loan on their
Bank account
a. Display first name ,middle name ,last name , mobile number for the customer
b. Display first name middle name and last name
c. Assign as message ‘not assigned ‘if middle name is not in database
d. Display mobile number in given format (444-656-9898)

Expected Result:
First Name Middle Name Last Name Contact number
Ramesh Chandra Sharma 954-431-9834
Avinash Sunder Minha 987-765-3210
Abhishek not assigned Dutta 985-561-9876
Shankar not assigned Nair 876-654-8907

You might also like