0% found this document useful (0 votes)
15 views

SP ex-2

The document outlines the design and implementation of a simple banking application using MySQL. It includes the creation of tables for banks, branches, accounts, loans, and clients, along with sample data insertion and selection queries. The structure ensures referential integrity through foreign key constraints between the tables.

Uploaded by

VENKATESH M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

SP ex-2

The document outlines the design and implementation of a simple banking application using MySQL. It includes the creation of tables for banks, branches, accounts, loans, and clients, along with sample data insertion and selection queries. The structure ensures referential integrity through foreign key constraints between the tables.

Uploaded by

VENKATESH M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Design and Implement Simple application using MySQL

Query:

USE BANK;

CREATE TABLE BANK(


bank_ID NUMERIC PRIMARY KEY,
bank_name VARCHAR(30) NOT NULL,
bank_address VARCHAR(30)
);

INSERT INTO BANK VALUES (1, 'Indian Bank', 'Chennai');


INSERT INTO BANK VALUES (2, 'Canara Bank', 'Coimbatore');
INSERT INTO BANK VALUES (3, 'Tamilnad Mercantile Bank', 'Madurai'); -- No truncation
INSERT INTO BANK VALUES (4, 'Karur Vysya Bank', 'Karur');
INSERT INTO BANK VALUES (5, 'City Union Bank', 'Kumbakonam');

SELECT * FROM BANK;

CREATE TABLE BRANCH(


bank_ID NUMERIC,
branch_ID NUMERIC PRIMARY KEY,
branch_name VARCHAR(30) NOT NULL,
branch_address VARCHAR(50),
FOREIGN KEY (bank_ID) REFERENCES BANK(bank_ID) ON DELETE CASCADE
);

INSERT INTO BRANCH VALUES (1, 101, 'Chennai', 'T. Nagar');


INSERT INTO BRANCH VALUES (2, 102, 'Coimbatore', 'Gandhipuram');
INSERT INTO BRANCH VALUES (3, 103, 'Madurai', 'Anna Nagar');
INSERT INTO BRANCH VALUES (4, 104, 'Trichy', 'Srirangam');
INSERT INTO BRANCH VALUES (5, 105, 'Salem', 'Hasthampatti');

SELECT * FROM BRANCH;

CREATE TABLE ACCOUNT(


account_ID NUMERIC PRIMARY KEY,
branch_ID NUMERIC,
name VARCHAR(30) NOT NULL,
account_type VARCHAR(30) NOT NULL,
FOREIGN KEY (branch_ID) REFERENCES BRANCH(branch_ID) ON DELETE CASCADE
);

INSERT INTO ACCOUNT VALUES (201, 101, 'Mathan', 'Salary Account');


INSERT INTO ACCOUNT VALUES (202, 102, 'Suresh', 'Saving Account');
INSERT INTO ACCOUNT VALUES (203, 103, 'Muthu', 'Fixed Deposit Account');
INSERT INTO ACCOUNT VALUES (204, 104, 'Saravana', 'Recurring Deposit Account');
INSERT INTO ACCOUNT VALUES (205, 105, 'Vicky', 'NRI Account');

SELECT * FROM ACCOUNT;

CREATE TABLE LOAN(


account_ID NUMERIC,
loan_ID NUMERIC PRIMARY KEY,
name VARCHAR(30) NOT NULL,
loan_type VARCHAR(30) NOT NULL,
loan_amount NUMERIC,
FOREIGN KEY (account_ID) REFERENCES ACCOUNT(account_ID) ON DELETE CASCADE
);
INSERT INTO LOAN VALUES (201, 301, 'Mathan', 'Personal Loan', 10000);
INSERT INTO LOAN VALUES (202, 302, 'Suresh', 'Home Loan', 20000);
INSERT INTO LOAN VALUES (203, 303, 'Muthu', 'Car Loan', 15000);
INSERT INTO LOAN VALUES (204, 304, 'Saravana', 'Education Loan', 25000);
INSERT INTO LOAN VALUES (205, 305, 'Vicky', 'Business Loan', 30000);

SELECT * FROM LOAN;

CREATE TABLE CLIENT(


account_ID NUMERIC,
client_ID NUMERIC PRIMARY KEY,
name VARCHAR(30) NOT NULL,
client_address VARCHAR(100) NOT NULL,
FOREIGN KEY (account_ID) REFERENCES ACCOUNT(account_ID) ON DELETE CASCADE
);

INSERT INTO CLIENT VALUES (201, 401, 'Mathan', '12, T. Nagar, Chennai');
INSERT INTO CLIENT VALUES (202, 402, 'Suresh', '45, Gandhipuram, Coimbatore');
INSERT INTO CLIENT VALUES (203, 403, 'Muthu', '67, Anna Nagar, Madurai');
INSERT INTO CLIENT VALUES (204, 404, 'Saravana', '23, Srirangam, Trichy');
INSERT INTO CLIENT VALUES (205, 405, 'Vicky', '89, Hasthampatti, Salem');
SELECT * FROM CLIENT;

Output:
For Table bank:
For Table Branch:

For Table Account:

For Table Loan:

For Table Client:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy