Church Cashbook Data Schema Manual
Chart-of-accounts entries referenced by transactions (debit/credit).
DDL source: uploaded
accounts.sql.Purpose
The accounts table stores the chart-of-accounts entries used by the double-entry engine. Each transaction references two accounts: a debit account and a credit account.
How it is used
- transactions.debit_account_id → accounts.id
- transactions.credit_account_id → accounts.id
- Church settings may store a “primary bank account” reference (governance-controlled).
Columns
- id —
intUNSIGNED NOT NULL - code —
varchar(30)NOT NULL - name —
varchar(200)NOT NULL - type —
enum('asset','liability','equity','income','expense') NOT NULL - is_active —
tinyint(1)NOT NULL DEFAULT '1' - is_dormant —
tinyint(1)NOT NULL DEFAULT '0'
Indexes
- PRIMARY KEY `id`
Constraints
- No foreign keys detected in pasted DDL.
Operational notes
- Immutability expectation: changing account meaning (e.g., code/name/type) can distort historical reporting. Prefer adding a new account and marking old ones dormant if needed.
- Bank governance: bank accounts may be treated specially (primary bank account, reconciliation/clearing workflows).
- RBAC: if accounts are church-scoped, all queries must constrain by church scope. If global, UI must still prevent cross-church leakage via joins.
DDL
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Feb 24, 2026 at 07:48 PM
-- Server version: 8.0.40
-- PHP Version: 8.3.14
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `church_accounts`
--
-- --------------------------------------------------------
--
-- Table structure for table `accounts`
--
CREATE TABLE `accounts` (
`id` int UNSIGNED NOT NULL,
`code` varchar(30) NOT NULL,
`name` varchar(200) NOT NULL,
`type` enum('asset','liability','equity','income','expense') NOT NULL,
`is_active` tinyint(1) NOT NULL DEFAULT '1',
`is_dormant` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `accounts`
--
ALTER TABLE `accounts`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `uq_accounts_code` (`code`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `accounts`
--
ALTER TABLE `accounts`
MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;