Data Model
Overview
BayanCore data model is built on MariaDB with ERPNext as the foundation. This document defines the key entities and relationships.
Core Entities
Organization
- Multi-tenant structure
- Company, branches, departments
- Settings and configurations
Users & Roles
- User profiles (linked to Clerk)
- Role-based access control
- Department assignments
Financial Entities
- Chart of Accounts
- Invoices (Sales/Purchase)
- Payments and Receipts
- Tax records (VAT, WHT)
Workflow Entities
- Workflow definitions
- Workflow instances
- Approval chains
- Audit trail entries
Compliance Entities
- ZATCA invoice records
- PDPL consent records
- Audit logs
- Compliance reports
Relationships
Organization
├── Users (many)
├── Departments (many)
│ └── Workflows (many)
├── Invoices (many)
│ ├── Line Items (many)
│ └── Payments (many)
└── Audit Logs (many)
Naming Conventions
- Tables:
snake_case, plural (e.g.,invoices,workflow_instances) - Columns:
snake_case(e.g.,created_at,organization_id) - Foreign keys:
{table}_id(e.g.,organization_id)