Church Cashbook Data Schema Manual
Per-FY opening balances (starting point for reports).
DDL source: uploaded
opening_balances.sql.Purpose
The opening_balances table stores the starting bank balance for a church for a given financial year. Reports (Monthly Summary, Year-End Pack) start from this figure to compute running/cumulative balances.
How it relates to the system
- Selected by church and financial year (FY start year or derived FY boundary).
- Used as the base for running balance calculations alongside
transactions.
Columns
- id —
intUNSIGNED NOT NULL - church_id —
intUNSIGNED NOT NULL - fy_year —
intUNSIGNED NOT NULL - account_id —
intUNSIGNED NOT NULL - amount —
decimal(12,2) NOT NULL DEFAULT '0.00'
Indexes
- PRIMARY KEY `id`
- idx_ob_church (`church_id`)
- fk_ob_account (`account_id`)
Constraints
- fk_ob_account:
account_id→accounts.id, ADD CONSTRAINT `fk_ob_church` FOREIGN KEY (`church_id`) REFERENCES `churches` (`id`) ON DELETE CASCADE
Operational notes
- Invariant: there should be at most one opening balance record per church per financial year.
- Governance: changing historical opening balances can distort prior-year reporting; changes should be restricted and logged.
- No deletion: avoid deleting opening balances; prefer correction-with-audit.
DDL
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Feb 24, 2026 at 08:00 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 `opening_balances`
--
CREATE TABLE `opening_balances` (
`id` int UNSIGNED NOT NULL,
`church_id` int UNSIGNED NOT NULL,
`fy_year` int UNSIGNED NOT NULL,
`account_id` int UNSIGNED NOT NULL,
`amount` decimal(12,2) NOT NULL DEFAULT '0.00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `opening_balances`
--
ALTER TABLE `opening_balances`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `uq_opening` (`church_id`,`fy_year`,`account_id`),
ADD KEY `idx_ob_church` (`church_id`),
ADD KEY `fk_ob_account` (`account_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `opening_balances`
--
ALTER TABLE `opening_balances`
MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `opening_balances`
--
ALTER TABLE `opening_balances`
ADD CONSTRAINT `fk_ob_account` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`),
ADD CONSTRAINT `fk_ob_church` FOREIGN KEY (`church_id`) REFERENCES `churches` (`id`) ON DELETE CASCADE;
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 */;