erDiagram
user {
uuid id PK
string userName UK "For sending money"
string email "For OTP"
string pin "Hashed"
bytea avatar "Optional, fallback oauth image"
string address "Optional"
string(10) phoneNumber "Optional (for contact)"
%% For what??
%% bool isActive
money balance "Default 0, constraint >= 0"
}
method {
int id PK "Auto inc"
string description
}
%% name??
rate {
int id PK "Auto inc"
int days
}
ticket {
uuid id PK
uuid userId FK
int methodId FK
int rateId FK
money initMoney "> 0"
timestamp issueDate
bool isOpen
}
%% need change the name
ticket_detail {
uuid ticketId FK
decimal percentage
date startDate
date endDate
bool isEnd "current date > endDate (constraint)"
}
transaction {
uuid userId FK "Index"
money amount
enum type "('deposit', 'withdraw', 'interest_payment')"
timestamp createdAt "Default now"
}
notification {
uuid userId FK "Index"
string title
string content
timestamp createdAt "Default now"
}
admin {
string username PK,UK
string password "Hashed"
}
user }o--|| ticket : has
user }o--|| transaction : has
user }o--|| notification : has
ticket ||--}o method : has
ticket ||--}o rate : has
ticket }|--|| ticket_detail : has