Token导航 LogoToken导航

Agent Skill · 研究检索

bookforge-inheritance-mapping-selector(bookforge 继承映射选择器)

bookforge-inheritance-mapping-selector 用于查找、检索和筛选相关信息,适合在 OpenClaw 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

bookforge-inheritance-mapping-selector 是研究检索类 Agent Skill,可用宿主为 OpenClaw,通过ClawHub获取,权限为调用外部服务;许可证为 MIT-0,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 27,741。

总安装 3,340周安装 142GitHub Stars 公开资料未说明下载 1,170核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT-0
版本
1.0.0

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:bookforge-inheritance-mapping-selector(bookforge 继承映射选择器)
来源仓库:https://github.com/quochungto/bookforge-inheritance-mapping-selector
安装命令:
openclaw skills install bookforge-inheritance-mapping-selector
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install bookforge-inheritance-mapping-selector

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

根据数据结构选择 STI、CTI 或具体表继承策略。适合数据库设计师与后端开发人员建模实体关系。权衡查询性能、扩展性与维护成本给出选型建议。输出依赖具体 ORM 框架特性可能有差异。复杂模型建议辅以原型测试验证方案。

bookforge-inheritance-mapping-selector 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 OpenClaw;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 openclaw skills install bookforge-inheritance-mapping-selector;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要调用外部服务,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

bookforge-inheritance-mapping-selector 怎么安装?

在终端执行 openclaw skills install bookforge-inheritance-mapping-selector。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

bookforge-inheritance-mapping-selector 支持哪些 AI 工具?

公开资料标注支持 OpenClaw。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

bookforge-inheritance-mapping-selector 需要什么权限?

权限级别是调用外部服务。该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

bookforge-inheritance-mapping-selector 是免费的吗?

来源标注的许可证是 MIT-0。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

bookforge-inheritance-mapping-selector 用的人多吗?

公开数据是累计安装 3,340 次,近一周安装 142 次,下载 1,170 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

bookforge-inheritance-mapping-selector 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 专注 OpenClaw 一种宿主,触发方式和使用习惯不用来回切换。
  • 许可证明确为 MIT-0,商用和分发边界好判断。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 OpenClaw,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。
  • 需要许可证清楚、并且有第三方扫描结果的团队项目。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
bookforge-inheritance-mapping-selector

bookforge 继承映射选择器 · 本页

3,340—调用外部服务MIT-0通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

name
inheritance-mapping-selector
description
|
version
1.0.0
homepage
https://github.com/bookforge-ai/bookforge-skills/tree/main/books/patterns-of-enterprise-application-architecture/skills/inheritance-mapping-selector
metadata
{"openclaw":{"emoji":"📚","homepage":"https://github.com/bookforge-ai/bookforge-skills"}}
status
draft
source-books
title
Patterns of Enterprise Application Architecture
authors
["Martin Fowler", "David Rice", "Matthew Foemmel", "Edward Hieatt", "Robert Mee", "Randy Stafford"]
chapters
[3, 12]
domain
software-architecture
tags
["inheritance-mapping", "orm", "persistence", "database-design", "design-patterns", "single-table-inheritance", "class-table-inheritance", "concrete-table-inheritance", "polymorphic-query", "object-relational-mapping", "fowler-peaa", "hibernate", "joined-table-inheritance"]
depends-on
[]
execution
tier
2
mode
hybrid
inputs
description
Description of the OO inheritance hierarchy (class names, field placement, depth), the ORM/framework in use, whether polymorphic reads are frequent, and any schema constraints (FK enforcement, external consumers, existing legacy schema).
tools-required
[Read, Write]
tools-optional
[Grep]
mcps-required
[]
environment
Any agent environment. Works from architecture docs, ORM model files, schema files, or a written domain description. Codebase access improves precision but is not required.
discovery
goal
Produce a concrete inheritance mapping recommendation with ORM config, SQL schema sketch, and migration path.
tasks
audience
roles
["software-architect", "senior-backend-engineer", "tech-lead", "database-designer"]
experience
intermediate
when_to_use
triggers
prerequisites
[]
not_for
environment
codebase_required
false
codebase_helpful
true
works_offline
true
quality
scores
with_skill
{filled by tester}
baseline
{filled by tester}
delta
{filled by tester}
tested_at
{filled by tester}
eval_count
{filled by tester}
assertion_count
13
iterations_needed
{filled by tester}

Inheritance Mapping Selector

When to Use

Relational databases have no native concept of inheritance. Every time an OO hierarchy needs to be persisted, a structural decision must be made: how does the class tree become table(s)? This skill routes that decision.

Apply this skill when:

  • You have an OO inheritance hierarchy and need to choose a database schema strategy
  • You are configuring @Inheritance in Hibernate/JPA or equivalent ORM annotation
  • Your current STI table has grown so wide that NULLs dominate most rows
  • Your current CTI (joined) queries are slow because every polymorphic read needs a multi-table join
  • You are refactoring a legacy schema where inheritance was never explicitly designed

Prerequisites: none. If the domain-logic pattern (Transaction Script / Domain Model) is not yet settled, clarify that first — it affects whether you need inheritance mapping at all.


Context & Input Gathering

Before scoring, collect:

InputWhy it matters
Class hierarchy diagram or descriptionReveals depth, abstract vs concrete classes, field placement
Subclass-specific field countHigh divergence → CTI or Concrete; low divergence → STI
Polymorphic read frequencyFrequent supertype queries penalize Concrete Table (UNION)
FK constraint requirementsSTI cannot enforce FK/NOT NULL on subclass-only columns
External DB consumersOther apps reading the schema favor Concrete (self-contained tables)
ORM/frameworkDetermines which strategies are idiomatically supported
Existing schema (if refactoring)Legacy constraints may limit options

Sufficiency check: You need at minimum the class hierarchy shape and an estimate of polymorphic read frequency. Everything else refines the recommendation.


Process

Step 1 — Map the hierarchy structure

List all classes: which are abstract, which are concrete, how deep the tree is, and where fields cluster.

*Why:* STI and CTI (joined) require a clear understanding of which classes share common fields. Concrete Table requires knowing all concrete classes, since each gets its own table. Deep hierarchies with many levels favor CTI; shallow hierarchies with low field divergence favor STI.

Step 2 — Score on six trade-off dimensions

For each of the three candidate strategies, score the trade-offs given this specific hierarchy:

DimensionSingle Table (STI)Class Table (CTI)Concrete Table
Joins on polymorphic readNone — single table query1 join per hierarchy levelUNION across all concrete tables
Wasted column spaceHigh — NULLs for irrelevant subclass columnsNone — each row fully relevantNone — each table is self-contained
FK constraint enforcementCannot enforce on subclass-only columnsFull enforcement possiblePer-table only; no FK to abstract supertypes
Ad-hoc query readabilityPoor — sparse rows, mixed types in one tableGood — normalized, clear schemaGood — each table is standalone and readable
Refactoring impact (field moves)None — push/pull fields up or down freelySchema change required per moveSchema change must propagate to all concrete tables
Polymorphism supportExcellent — single query for any typeGood — join required per levelPoor — UNION or multi-query required

*Why:* These six dimensions are the primary axes Fowler identifies for distinguishing the three patterns. Scoring them forces an explicit trade-off rather than defaulting to whichever the ORM does by default.

Step 3 — Apply the primary routing rule

Use the dominant signals to select a strategy:

→ Single Table Inheritance when:

  • Few subclass-specific columns (most fields live on the superclass)
  • Polymorphic reads are frequent and join cost is a concern
  • Refactoring the hierarchy is likely (field promotions/demotions should not require schema migration)
  • Constraints on subclass columns are not needed

→ Class Table Inheritance (Joined) when:

  • Subclasses have substantially divergent fields (many NULL columns in STI would be a problem)
  • FK integrity on subclass-specific columns is required
  • Domain model clarity matters to DBAs or reporting tools
  • Polymorphic read frequency is moderate (joins are acceptable)

→ Concrete Table Inheritance when:

  • Subclasses are largely independent (rarely queried polymorphically)
  • Other applications or reporting tools read the database directly and benefit from standalone tables
  • Each concrete class stands alone with a full, self-contained schema

*Why:* Fowler offers no single universal recommendation — the decision is genuinely context-dependent. But each strategy has dominant use cases where it wins cleanly.

Step 4 — Check for mixing

Evaluate whether different branches of the hierarchy have significantly different trade-off profiles.

IF the hierarchy has a stable branch with few subclass fields (STI-favorable) AND a divergent branch with many subclass-specific fields and constraint needs (CTI-favorable): → Use Inheritance Mappers as the coordinator layer and apply different strategies per branch.

Fowler explicitly permits this: "The trio of inheritance patterns can coexist in a single hierarchy."

*Why:* Mixing avoids forcing the entire hierarchy into the strategy that fits only the worst-case branch. The Inheritance Mappers pattern provides the implementation scaffold — an abstract mapper per class plus a separate coordinator mapper for the supertype — that makes mixed strategies workable without duplicating load/save logic.

Step 5 — Map to ORM idiom

Translate the chosen strategy to the team's ORM:

ORMSTICTI (Joined)Concrete Table
Hibernate/JPA@Inheritance(strategy = InheritanceType.SINGLE_TABLE) + @DiscriminatorColumn@Inheritance(strategy = InheritanceType.JOINED)@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
Rails ActiveRecordBuilt-in: add type:string column; subclass AR classNot natively supported (requires manual joins or gems)Not natively supported
Django ORMAbstract base (no shared table, no polymorphism)Multi-Table Inheritance (default model inheritance)Proxy models (no new table, same table)
SQLAlchemypolymorphic_on=type_col, single_table_inheritancejoined_table_inheritanceconcrete_table_inheritance
Doctrine (PHP)@InheritanceType("SINGLE_TABLE")@InheritanceType("JOINED")@InheritanceType("TABLE_PER_CLASS")

Note: Hibernate's TABLE_PER_CLASS (Concrete) generates UNION queries automatically for polymorphic finds. This convenience hides the performance cost — monitor actual query plans.

*Why:* The choice must translate to idiomatic ORM configuration. Choosing CTI and then fighting the ORM defaults erodes the benefit.

Step 6 — Produce the decision record

Write the inheritance mapping decision record (see Outputs).


Inputs

  • Required: OO inheritance hierarchy (class names, field locations, depth, abstract vs. concrete)
  • Required: Polymorphic read frequency estimate (high / medium / low)
  • Helpful: ORM/framework in use
  • Helpful: FK constraint and data integrity requirements
  • Helpful: Whether other systems read the database directly
  • Helpful: Existing schema (if refactoring)

Outputs

Inheritance Mapping Decision Record containing:

## Inheritance Mapping Decision — [Hierarchy Name]

### Hierarchy Summary
[Superclass] → [Subclasses list]
Abstract classes: [list]
Concrete classes: [list]
Field distribution: [X fields on superclass, Y per subclass avg]

### Six-Dimension Score
| Dimension           | STI | CTI | Concrete |
|---------------------|-----|-----|----------|
| Joins               | ✅  | ⚠️  | ❌       |
| Wasted space        | ⚠️  | ✅  | ✅       |
| FK enforcement      | ❌  | ✅  | ⚠️       |
| Ad-hoc readability  | ⚠️  | ✅  | ✅       |
| Refactoring impact  | ✅  | ⚠️  | ⚠️       |
| Polymorphism cost   | ✅  | ⚠️  | ❌       |

### Recommendation
**Primary strategy:** [STI / CTI / Concrete / Mixed]
**Rationale:** [2-3 sentences]

### SQL Schema Sketch
[simplified CREATE TABLE statements]

### ORM Configuration
[annotated class snippet for the team's ORM]

### Mixing Note
[IF mixing: which branches use which strategy, and why]

### Migration Path
[steps to get from current state to chosen strategy]

Key Principles

1. Single Table is Fowler's default for simple hierarchies — with explicit caveats. STI wins on query simplicity and refactoring tolerance. Its costs (NULLs, no constraints) are real but manageable for hierarchies with few subclass-specific fields. Fowler's own Player/Footballer/Cricketer example uses it as the primary illustration. The caveat: once subclass-specific field count grows substantially, the NULL bloat and constraint inability become genuine liabilities.

2. Class Table (Joined) buys normalization at the cost of joins — and joins compound with depth. CTI is the most "object-aligned" strategy: one table per class mirrors the class hierarchy. Its cost is that loading any object requires touching multiple tables. For a two-level hierarchy (parent + one child table), one join is tolerable. For a four-level hierarchy, you may be joining four tables per load. Monitor query plans; the supertype table also becomes a bottleneck since every query touches it.

3. Concrete Table's UNION penalty is the silent killer. Concrete Table looks attractive in isolation: no joins, no NULLs, self-contained tables. The danger emerges when someone queries at the supertype level. The ORM (or developer) must UNION all concrete tables. As the hierarchy grows, this query becomes increasingly expensive. Concrete Table is appropriate only when polymorphic supertype queries are rare or absent.

4. FK constraints are incompatible with STI for subclass-specific columns. If a Footballer must have a club and that column must be NOT NULL and FK-constrained, STI cannot enforce this — the column exists on all rows, including Cricketers who have no club. CTI (or Concrete) is required when FK integrity on subclass fields is non-negotiable.

5. Mixing is the escape hatch — use it deliberately, not ad-hoc. Fowler explicitly endorses mixing strategies within one hierarchy. The right way to implement mixing is the Inheritance Mappers pattern: each class has its own mapper (abstract or concrete), and a separate coordinator mapper handles supertype-level operations. Do not mix strategies without this scaffolding — the result is tangled load/save logic that is difficult to maintain.

6. Keys must be unique across all tables in Concrete Table — the database won't enforce this for you. When using Concrete Table, the database's primary key constraint only guarantees uniqueness within one table. A Footballer with id=42 and a Cricketer with id=42 are valid in the database — but they will collide on any polymorphic Identity Field lookup. You need a cross-table key allocation strategy (e.g., a shared sequence, UUID keys, or application-level key tracking).


Examples

Example 1: Sports Player Hierarchy (STI recommended)

Scenario: SportsDB system models Player (name, dateOfBirth) with three subclasses: Footballer (club, position), Cricketer (battingAverage), Bowler (bowlingSpeed, bowlingStyle). The application frequently loads "all active Players" for reporting and roster views. Hierarchy is unlikely to deepen further.

Trigger: "Should we use STI or separate tables for Player/Footballer/Cricketer? We need to query all players at once frequently."

Process:

  1. Hierarchy: 3 concrete classes, 1 abstract base. Subclass-specific fields: 1–2 per subclass. Field divergence is low.
  2. Dimension score: STI wins on joins (none), refactoring tolerance (none), polymorphism (single query). Cost: wasted columns for ~2–3 nullable columns per row — tolerable. No FK constraint requirement on club or battingAverage.
  3. Routing: STI. Fowler uses this exact example to demonstrate Single Table Inheritance.
  4. Mixing: Not needed — all branches are similar in shape.
  5. ORM config: Hibernate @Inheritance(SINGLE_TABLE) with @DiscriminatorColumn(name="type") on Player; @DiscriminatorValue("F") on Footballer.

Output (schema sketch):

CREATE TABLE players (
  id         BIGINT PRIMARY KEY,
  type       VARCHAR(1) NOT NULL,      -- discriminator: F, C, B
  name       VARCHAR(100) NOT NULL,
  club       VARCHAR(100),             -- Footballer only
  batting_avg DECIMAL(5,2),            -- Cricketer only
  bowling_speed INT,                   -- Bowler only
  bowling_style VARCHAR(50)            -- Bowler only
);

Example 2: Organization Hierarchy with Strict Constraints (CTI recommended)

Scenario: HR system with LegalEntity (taxId, registeredAddress) as abstract base, Corporation (stockExchange, tickerSymbol), Partnership (partnerCount), SoleTrader (tradingName) as concrete subclasses. Every Corporation must have a non-null stockExchange. The compliance team requires FK integrity on all subtype-specific columns. Polymorphic reads ("load any LegalEntity by id") occur at application startup only; most queries are type-specific.

Trigger: "We need strict FK constraints on Corporation fields. Can we still use inheritance?"

Process:

  1. Hierarchy depth: 2 levels. Subclass fields: 3–5 per subclass, highly divergent.
  2. Dimension score: FK enforcement → CTI required (STI cannot enforce NOT NULL on stockExchange for Corporations). Refactoring impact acceptable (hierarchy is stable by design). Polymorphic reads are infrequent → join cost acceptable.
  3. Routing: Class Table Inheritance (Joined). Hibernate @Inheritance(JOINED).
  4. Mixing: Not needed.

Output (schema sketch):

CREATE TABLE legal_entities (id BIGINT PRIMARY KEY, tax_id VARCHAR(20), address TEXT, type VARCHAR(20));
CREATE TABLE corporations (id BIGINT REFERENCES legal_entities(id), stock_exchange VARCHAR(10) NOT NULL, ticker VARCHAR(10) NOT NULL);
CREATE TABLE partnerships (id BIGINT REFERENCES legal_entities(id), partner_count INT NOT NULL);
CREATE TABLE sole_traders (id BIGINT REFERENCES legal_entities(id), trading_name VARCHAR(100) NOT NULL);

Example 3: Independent Product Types, Rarely Queried Polymorphically (Concrete recommended)

Scenario: E-commerce catalog with Product as abstract base and three highly divergent concrete types: PhysicalProduct (weight, dimensions, shippingClass), DigitalProduct (fileSize, downloadUrl, licenseType), SubscriptionProduct (billingCycle, trialDays, renewalPolicy). Each has 8–12 unique fields. The reporting team queries each type independently ("all digital downloads this month"). Polymorphic "all products" queries exist only in one admin view.

Trigger: "Our Product table is a mess — 40 columns, half NULL on any given row. What's the alternative?"

Process:

  1. Subclass fields: 8–12 per subclass, highly divergent. Only 3 shared fields on Product (id, name, price).
  2. Dimension score: Current STI is the problem (wasted space). Concrete Table wins on no NULLs, self-contained tables, per-class query performance. Cost: polymorphic "all products" query → UNION. But this query is rare (one admin view).
  3. Routing: Concrete Table Inheritance. Cross-table key uniqueness → use UUID primary keys.
  4. Key uniqueness: UUIDs eliminate the cross-table collision problem.
  5. Polymorphic admin view: Accept a UNION query here — document the performance expectation; cache if needed.

Output (schema sketch):

CREATE TABLE physical_products (id UUID PRIMARY KEY, name VARCHAR, price DECIMAL, weight_kg DECIMAL, dim_cm VARCHAR, shipping_class VARCHAR);
CREATE TABLE digital_products (id UUID PRIMARY KEY, name VARCHAR, price DECIMAL, file_size_mb INT, download_url TEXT, license_type VARCHAR);
CREATE TABLE subscription_products (id UUID PRIMARY KEY, name VARCHAR, price DECIMAL, billing_cycle VARCHAR, trial_days INT, renewal_policy VARCHAR);
-- Polymorphic admin query:
SELECT id, name, price, 'physical' AS type FROM physical_products
UNION ALL SELECT id, name, price, 'digital' FROM digital_products
UNION ALL SELECT id, name, price, 'subscription' FROM subscription_products;

References

  • references/six-dimension-trade-off-matrix.md — Full trade-off matrix with rationale per cell and worked examples
  • references/inheritance-mappers-scaffold.md — Inheritance Mappers implementation pattern for mixed-strategy hierarchies
  • references/orm-config-reference.md — ORM configuration snippets for Hibernate, Rails, Django, SQLAlchemy, Doctrine

License

This skill is licensed under CC-BY-SA-4.0. Source: BookForge — Patterns of Enterprise Application Architecture by Martin Fowler, David Rice, Matthew Foemmel, Edward Hieatt, Robert Mee, Randy Stafford.


Related BookForge Skills

Install related skills from ClawhHub:

  • clawhub install bookforge-data-source-pattern-selector
  • clawhub install bookforge-object-relational-structural-mapping-guide

Or install the full book set from GitHub: bookforge-skills

平台分布

OpenClaw

88.97%
按下载量换算1,041

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

通过

权限和风险

调用外部服务

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills