Create database entities
---
title: Fyme's Entity Relationship Diagram
---
erDiagram
USER {
int userId PK
string userName
string email
string name
string aud
}
USER ||--o{ ACCOUNT : owns
USER ||--o{ ENTITY : creates
ACCOUNT {
int accountId PK
int ownerId FK
string name
}
ACCOUNT ||--o{ EXPENSE : spends
ACCOUNT ||--o{ INCOME : receives
ACCOUNT ||--o{ TRANSFER : "transfers from/to"
TRANSACTION {
int transactionId PK
float amount
timestamp transactionDate
string notes
}
TRANSACTION ||--|| EXPENSE : is
TRANSACTION ||--|| INCOME : is
TRANSACTION ||--|| TRANSFER : is
TRANSACTION ||--o{ TRANSACTION_LABEL : has
LABEL {
int labelId PK
int accountId FK "can be NULL if label is global to all user's accounts"
string name
string color
}
LABEL ||--o{ TRANSACTION_LABEL : labels
TRANSACTION_LABEL {
int transactionLabelId PK
int transactionId FK
int labelId FK
}
EXPENSE {
int expenseId PK
int transactionId FK
int senderAccountId FK
int receiverEntityId FK
}
INCOME {
int incomeId PK
int transactionId FK
int senderEntityId FK
int receiverAccountId FK
}
TRANSFER {
int transferId PK
int transactionId FK
int senderAccountId FK
int receiverAccountId FK
}
ENTITY {
int entityId PK
int createdBy FK
enum kind "'person' or 'org'"
string name
}
ENTITY ||--o{ EXPENSE : receives
ENTITY ||--o{ INCOME : sends
Edited by Robin Bourachot