-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathBanking Management queries.txt
70 lines (56 loc) · 1.59 KB
/
Banking Management queries.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--Bank--
CREATE TABLE T_Bank(
Bank_Code INTEGER NOT NULL,
Bank_Name VARCHAR(30),
Bank_Address VARCHAR(15),
PRIMARY KEY(Bank_Code));
--Bank Sequence--
CREATE SEQUENCE bank_code_sequence
INCREMENT BY 1;
--Branch--
Create TABLE T_Branch(
Branch_ID INTEGER NOT NULL,
Branch_Name VARCHAR(20),
Branch_Address VARCHAR(30),
Bank_Code int,
PRIMARY KEY(Branch_ID),
CONSTRAINT fk_bank_code FOREIGN KEY(Bank_Code) REFERENCES T_Bank(Bank_Code));
--Branch Sequence--
CREATE SEQUENCE branch_id_sequence
INCREMENT BY 1;
--Customer--
Create TABLE T_Customer(
Cust_ID INTEGER NOT NULL,
Cust_Name VARCHAR(20),
Cust_Phone INTEGER,
Cust_Address VARCHAR(30),
PRIMARY KEY(Cust_ID));
--Customer Sequence--
CREATE SEQUENCE customer_id_sequence
INCREMENT BY 1;
--Account--
Create TABLE T_Account(
Account_Number INTEGER NOT NULL,
Account_Type VARCHAR(20),
Account_Balance INTEGER,
Branch_ID int,
Cust_ID int,
PRIMARY KEY(Account_Number),
CONSTRAINT fk_branch_id FOREIGN KEY(Branch_ID) REFERENCES T_Branch(Branch_ID),
CONSTRAINT fk_cust_id FOREIGN KEY(Cust_ID) REFERENCES T_Customer(Cust_ID));
--Account Sequence--
CREATE SEQUENCE account_id_sequence
INCREMENT BY 1;
--LOAN--
Create TABLE T_Loan(
Loan_ID INTEGER NOT NULL,
Loan_Type VARCHAR(20),
Loan_Amount INTEGER,
Branch_ID int,
Cust_ID int,
PRIMARY KEY(Loan_ID),
CONSTRAINT fk_branch_id1 FOREIGN KEY(Branch_ID) REFERENCES T_Branch(Branch_ID),
CONSTRAINT fk_cust_id1 FOREIGN KEY(Cust_ID) REFERENCES T_Customer(Cust_ID));
--Loan Sequence--
CREATE SEQUENCE loan_id_sequence
INCREMENT BY 1;