-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb.sql
More file actions
55 lines (50 loc) · 1.58 KB
/
Copy pathdb.sql
File metadata and controls
55 lines (50 loc) · 1.58 KB
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
-- Table for Bank details
CREATE TABLE Banks (
BankID INTEGER PRIMARY KEY AUTOINCREMENT,
BankName TEXT NOT NULL,
Website TEXT
);
-- Table for Account Types
CREATE TABLE AccountTypes (
AccountTypeID INTEGER PRIMARY KEY AUTOINCREMENT,
BankID INTEGER,
Type ENUM('Savings', 'Checking', 'Fixed Deposit', 'Business') NOT NULL,
PackageName TEXT,
MinimumBalance DECIMAL(10, 2),
MonthlyFee DECIMAL(10, 2),
WithdrawalFee TEXT,
CashDepositFee TEXT,
OnlineTransactionalFee DECIMAL(10, 2),
SMSNotificationFee DECIMAL(10, 2),
InternalDebitOrderFee DECIMAL(10, 2),
ExternalDebitOrderFee DECIMAL(10, 2),
FOREIGN KEY (BankID) REFERENCES Banks(BankID)
);
-- Table for Interest Rates
CREATE TABLE InterestRates (
RateID INTEGER PRIMARY KEY AUTOINCREMENT,
AccountTypeID INTEGER,
RangeDescription TEXT,
NominalRate DECIMAL(10, 2),
EffectiveRate DECIMAL(10, 2),
FOREIGN KEY (AccountTypeID) REFERENCES AccountTypes(AccountTypeID)
);
-- Table for Users
CREATE TABLE Users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL UNIQUE,
password TEXT NOT NULL,
role TEXT NOT NULL CHECK(role IN ('admin', 'user'))
);
-- Create a View to get user data
CREATE VIEW UserData AS
SELECT AccountTypes.AccountTypeID AS id,
AccountTypes.PackageName AS name,
AccountTypes.Type
FROM AccountTypes
WHERE AccountTypes.Type = 'Savings';
-- Insert sample Users
INSERT INTO Users (username, password, role)
VALUES
('admin_user', 'hashed_password_here', 'admin'),
('regular_user', 'hashed_password_here', 'user');