Church Cashbook Data Schema Manual
Per-church category mapping used by transactions and budgets.
DDL source: uploaded
church_categories.sql.Purpose
The church_categories table represents the category list available to a specific church. Transactions typically store a church_category_id to classify income/expense for reporting and budgeting.
How it relates to the system
- transactions.church_category_id →
church_categories.id(nullable FK) - budgets are typically recorded per church category (exact linkage confirmed from
budgetsDDL). - May be derived from (or aligned with)
master_categoriesfor standardisation.
Columns
- id —
intUNSIGNED NOT NULL - church_id —
intUNSIGNED NOT NULL - master_category_id —
intUNSIGNED NOT NULL - local_name —
varchar(150)NOT NULL - is_active —
tinyint(1)NOT NULL DEFAULT '1' - created_at —
datetimeNOT NULL DEFAULT CURRENT_TIMESTAMP
Indexes
- PRIMARY KEY `id`
- idx_cc_master (`master_category_id`)
Constraints
- fk_cc_church:
church_id→churches.idON DELETE CASCADE, ADD CONSTRAINT `fk_cc_master` FOREIGN KEY (`master_category_id`) REFERENCES `master_categories` (`id`)
Operational notes
- Governance: categories drive reporting lines; renaming categories affects report readability historically.
- Integrity: avoid deletion if referenced by transactions; prefer marking inactive/dormant if supported.
DDL
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Feb 24, 2026 at 07:56 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 `church_categories`
--
CREATE TABLE `church_categories` (
`id` int UNSIGNED NOT NULL,
`church_id` int UNSIGNED NOT NULL,
`master_category_id` int UNSIGNED NOT NULL,
`local_name` varchar(150) NOT NULL,
`is_active` tinyint(1) NOT NULL DEFAULT '1',
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `church_categories`
--
ALTER TABLE `church_categories`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `uq_church_local_name` (`church_id`,`local_name`),
ADD KEY `idx_cc_master` (`master_category_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `church_categories`
--
ALTER TABLE `church_categories`
MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `church_categories`
--
ALTER TABLE `church_categories`
ADD CONSTRAINT `fk_cc_church` FOREIGN KEY (`church_id`) REFERENCES `churches` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `fk_cc_master` FOREIGN KEY (`master_category_id`) REFERENCES `master_categories` (`id`);
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 */;