-
Notifications
You must be signed in to change notification settings - Fork 0
/
bank.sql
35 lines (32 loc) · 1.01 KB
/
bank.sql
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
CREATE TABLE IF NOT EXISTS Responsible (
responsible_id SERIAL PRIMARY KEY,
firstname VARCHAR(100) NOT NULL,
lastname VARCHAR(100) NOT NULL,
mail VARCHAR(100) NOT NULL,
pwd VARCHAR(100) NOT NULL,
FK_CUSTOMER_ID INTEGER DEFAULT NULL
);
CREATE TABLE IF NOT EXISTS Customer (
customer_id SERIAL PRIMARY KEY,
firstname VARCHAR(100) NOT NULL,
lastname VARCHAR(100) NOT NULL,
mail VARCHAR(100) NOT NULL,
pwd VARCHAR(100) NOT NULL,
FK_RESPONSIBLE_ID INTEGER DEFAULT NULL
);
CREATE TABLE IF NOT EXISTS BankAccount (
account_id SERIAL PRIMARY KEY,
card_number VARCHAR(16) NOT NULL,
validity_date DATE NOT NULL,
cryptogram integer NOT NULL,
FK_CUSTOMER_ID INTEGER NOT NULL,
amount integer NOT NULL DEFAULT 0,
autorizedOverdraft integer NOT NULL,
alert boolean NOT NULL DEFAULT false
);
CREATE TABLE IF NOT EXISTS Transactions(
transaction_id SERIAL PRIMARY KEY,
FK_SENDER INTEGER NOT NULL,
FK_RECEIVER INTEGER NOT NULL,
date_transaction DATE DEFAULT NOW()
);