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

Bank Database

The document describes a bank database with 6 tables: customer, branch, account, depositor, loan, and borrower. The customer table stores customer information. The branch table stores bank branch locations and assets. The account table links accounts to branches and stores balances. The depositor table links customers to their accounts. The loan table stores loan details. And the borrower table links customers to the loans they have taken. Data is inserted into each table.

Uploaded by

ghaith rustom
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
558 views

Bank Database

The document describes a bank database with 6 tables: customer, branch, account, depositor, loan, and borrower. The customer table stores customer information. The branch table stores bank branch locations and assets. The account table links accounts to branches and stores balances. The depositor table links customers to their accounts. The loan table stores loan details. And the borrower table links customers to the loans they have taken. Data is inserted into each table.

Uploaded by

ghaith rustom
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

/**********************************

Bank database with 6 tables


*/

DROP DATABASE IF EXISTS bank;


CREATE DATABASE bank;

USE bank;

CREATE TABLE customer (


customer_nr INT,
customer_name VARCHAR(20),
city VARCHAR(30),
primary key (customer_nr)
);

INSERT INTO customer VALUES( 100,"Jones", "Brooklyn");


INSERT INTO customer VALUES( 101,"Smith", "Rye" );
INSERT INTO customer VALUES(102, "Hayes", "Brooklyn" );
INSERT INTO customer VALUES( 103,"Curry", "Rye" );
INSERT INTO customer VALUES( 104,"Lindsay", "Bennington" );
INSERT INTO customer VALUES( 105,"Turner", "Stamford" );
INSERT INTO customer VALUES( 106,"Williams", "Pittsfield" );
INSERT INTO customer VALUES(107, "Johnson", "Palo" );

CREATE TABLE branch (


branch_name CHAR(15),
branch_city VARCHAR(30),
assets INT,
primary key (branch_name)
);

INSERT INTO branch VALUES( "Downtown","Brooklyn",9000000 );


INSERT INTO branch VALUES( "Redwood","Palo", 2100000);
INSERT INTO branch VALUES( "Perryridge","Horseneck", 1700000);
INSERT INTO branch VALUES( "Mianus","Horseneck",400000 );
INSERT INTO branch VALUES( "Round Hill","Horseneck",8000000 );
INSERT INTO branch VALUES( "Pownal","Bennington",300000 );
INSERT INTO branch VALUES( "Northtown","Rye",3700000 );
INSERT INTO branch VALUES( "Brighton","Brooklyn",7100000 );

CREATE TABLE account (


account_nr CHAR(10),
branch_name CHAR(15),
balance INT,
primary key (account_nr)
);

INSERT INTO account VALUES("D1000" ,"Downtown",1000 );


INSERT INTO account VALUES("D1001","Downtown",1500 );
INSERT INTO account VALUES("D1002" ,"Round Hill",3000 );
INSERT INTO account VALUES( "D1003","Brighton",5000 );
INSERT INTO account VALUES( "D1004","Redwood",1200 );
INSERT INTO account VALUES("D1005" ,"Brighton",700 );
INSERT INTO account VALUES("D1006" ,"Pownal",1000 );
INSERT INTO account VALUES( "D1007","Brighton",500 );
CREATE TABLE depositor (
customer_nr INT,
account_nr CHAR(10),
primary key (customer_nr,account_nr)
);
INSERT INTO depositor VALUES(100 ,"D1005" );
INSERT INTO depositor VALUES( 102,"D1003" );
INSERT INTO depositor VALUES(103 ,"D1007" );
INSERT INTO depositor VALUES(107 ,"D1004" );
INSERT INTO depositor VALUES(104 ,"D1006" );
INSERT INTO depositor VALUES(103 ,"D1000" );
INSERT INTO depositor VALUES( 102,"D1001" );
INSERT INTO depositor VALUES(106 ,"D1002" );

CREATE TABLE loan (


branch_name CHAR(15),
loan_nr CHAR(10),
amount INT,
primary key (loan_nr)
);

INSERT INTO loan VALUES( "Downtown","L17",1000 );


INSERT INTO loan VALUES( "Redwood","L23",2000 );
INSERT INTO loan VALUES( "Perryridge","L15",1500 );
INSERT INTO loan VALUES( "Downtown","L14",1500 );
INSERT INTO loan VALUES( "Round Hill","L11",900 );
INSERT INTO loan VALUES( "North Town","L16",1300 );
INSERT INTO loan VALUES( "Downtown","L18",2000 );
INSERT INTO loan VALUES( "Brighton","L10",2200 );

CREATE TABLE borrower (


customer_nr INT,
loan_nr CHAR(10),
primary key (customer_nr,loan_nr)
);
INSERT INTO borrower VALUES( 101,"L16" );
INSERT INTO borrower VALUES( 100,"L17" );
INSERT INTO borrower VALUES( 102,"L14" );
INSERT INTO borrower VALUES( 107,"L23" );
INSERT INTO borrower VALUES( 100,"L10" );
INSERT INTO borrower VALUES( 102,"L18" );
INSERT INTO borrower VALUES( 105,"L11" );
INSERT INTO borrower VALUES( 106,"L15" );

You might also like