Token导航 LogoToken导航

Agent Skill · 研究检索

bookforge-object-relational-structural-mapping-guide(Bookforge 对象关系结构映射指南)

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

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

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

安装说明

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

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:bookforge-object-relational-structural-mapping-guide(Bookforge 对象关系结构映射指南)
来源仓库:https://github.com/quochungto/bookforge-object-relational-structural-mapping-guide
安装命令:
openclaw skills install bookforge-object-relational-structural-mapping-guide
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

ClawHubOpenClaw
openclaw skills install bookforge-object-relational-structural-mapping-guide

这个 Skill 是做什么的

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

指导域对象到关系表的映射设计,规范身份字段和外键使用。适用于数据库设计、ORM 配置和领域模型优化。输入对象结构和表设计,输出映射建议和反范式提示。不涉及代码执行,但需确认是否适配特定 ORM 框架。

安装命令:openclaw skills install bookforge-object-relational-structural-mapping-guide

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

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

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

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

常见问题

6 条

bookforge-object-relational-structural-mapping-guide 怎么安装?

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

bookforge-object-relational-structural-mapping-guide 支持哪些 AI 工具?

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

bookforge-object-relational-structural-mapping-guide 需要什么权限?

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

bookforge-object-relational-structural-mapping-guide 是免费的吗?

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

bookforge-object-relational-structural-mapping-guide 用的人多吗?

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

bookforge-object-relational-structural-mapping-guide 安全吗?

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

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

值得选的地方

  • 专注 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-object-relational-structural-mapping-guide

Bookforge 对象关系结构映射指南 · 本页

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

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

SKILL.md 原文

name
object-relational-structural-mapping-guide
description
Object-relational mapping structural patterns guide. Use when designing or auditing how domain objects map to relational tables — identity fields, foreign key mapping, association table mapping for many-to-many relationships, dependent mapping for child objects with cascade delete, embedded value for value object mapping, and serialized LOB for JSON column or blob storage. Applies when choosing ORM associations (Hibernate, SQLAlchemy, EF Core, ActiveRecord, Django ORM), deciding between a join table and nested foreign keys, mapping address or money value objects as inline columns, or detecting serialized LOB overuse on queryable data. Covers the six PEAA structural patterns: Identity Field (surrogate key vs meaningful key), Foreign Key Mapping (single-valued reference), Association Table Mapping (many-to-many via join table), Dependent Mapping (child lifecycle owned by parent), Embedded Value (value object as columns), Serialized LOB (graph serialized to JSON/BLOB column).
version
1.0.0
homepage
https://github.com/bookforge-ai/bookforge-skills/tree/main/books/patterns-of-enterprise-application-architecture/skills/object-relational-structural-mapping-guide
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
persistence
tags
depends-on
[]
execution
tier
2
mode
hybrid
inputs
description
Domain model classes, existing ORM mappings, schema SQL/migrations, and build files (to detect ORM in use)
description
Domain model relationships to map, current pain points (N+1, cascade failures, unmappable queries), and ORM stack
tools-required
tools-optional
mcps-required
[]
environment
Enterprise application codebase with OO domain model and relational database. ORM stack detectable from build files or imports. Schema available as .sql, migrations, or ORM model definitions.
discovery
goal
Map every relationship and value structure in a domain model to the correct PEAA structural pattern, producing a structural mapping design document with schema sketches and ORM config for each.
tasks
audience
roles
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}

Object-Relational Structural Mapping Guide

Six PEAA patterns that bridge between OO domain objects and relational tables: Identity Field, Foreign Key Mapping, Association Table Mapping, Dependent Mapping, Embedded Value, and Serialized LOB.

When to Use

Use this skill when you are:

  • Designing how a domain model maps to a relational schema for the first time
  • Auditing an existing ORM configuration and schema for structural problems
  • Deciding how to map a specific relationship type (1:1, 1:N, N:M, value object, child graph)
  • Evaluating whether a JSON/BLOB column is the right choice for nested data
  • Debugging N+1 queries, cascade failures, or query-impossible data buried in a LOB

Not for:

  • Inheritance hierarchies → use inheritance-mapping-selector
  • Data-source gateway selection (Active Record vs Data Mapper) → use data-source-pattern-selector

Context & Input Gathering

Gather before proceeding:

Required:

  • List of domain classes with their relationships and cardinalities (1:1, 1:N, N:M)
  • Which objects are value objects (no identity, owned by another object) vs. entities (independent identity)
  • ORM stack in use (Hibernate/JPA, EF Core, SQLAlchemy, Django, ActiveRecord, TypeORM, or hand-rolled)

Observable from codebase:

  • Existing ORM annotations / model definitions (detect from @Entity, models.Model, Column, etc.)
  • Schema migrations or DDL files (detect FK patterns, join tables, LOB columns)
  • Build files (pom.xml, requirements.txt, *.csproj, Gemfile) to confirm ORM version

Ask if absent:

  • "Which classes have independent lifecycles (can be loaded/deleted on their own)?"
  • "Are there many-to-many relationships? Do the associations carry their own attributes (e.g., a role or start date)?"
  • "Is there any data currently stored as XML, JSON, or binary blob? What SQL queries run against it?"

Sufficiency check: Proceed once you have the domain class list, relationship cardinalities, and a yes/no on value object identity. ORM stack helps with the output but is not blocking.

Process

Step 1 — Identify all domain structures

For each domain class and relationship, classify it into one of these structural types:

TypeSignal
Entity with identityCan be loaded/deleted independently; has a unique ID
Value objectNo independent identity; always belongs to one owner (Money, Address, DateRange)
Single-valued referenceOne object holds a reference to exactly one other entity
Collection reference (1:N)One object holds a collection of other entities; each child knows its parent
Many-to-many referenceBoth sides hold collections pointing at each other
Dependent childChild exists only in the context of an owner; no external references to child
Complex nested graphHierarchical or graph structure that would require many joins relationally

*WHY:* Each structural type maps to exactly one pattern. Misclassifying here leads to wrong pattern choice (e.g., treating a Value Object as an entity creates an unnecessary table and Identity Map entry).

Step 2 — Apply the pattern routing table

StructurePatternKey rule
Every persistable entityIdentity FieldUse surrogate (auto-assigned) key — never meaningful keys
Single-valued reference (1:1, N:1)Foreign Key MappingFK lives in the "many" or "child" table
1:N collection (entity children)Foreign Key MappingFK lives in child table; parent has collection in memory, not in the table
N:M relationshipAssociation Table MappingAlways use a join table — even if no attributes today
Child with no independent identityDependent MappingNo Identity Field on child; owner mapper handles all persistence
Value object (DDD Value Object)Embedded ValueMap value's fields as columns on the owner's table
Non-queryable complex subgraphSerialized LOBOnly when SQL queries will NEVER need to filter by content

*WHY:* This routing table encodes the core insight that objects and relations have fundamentally different link representations. Without this explicit classification, teams default to wrong choices: adding FK columns for N:M (violates first normal form), creating tables for value objects (unnecessary complexity), or Serialized LOB for data later needing SQL queries (queryability trap).

Step 3 — Apply Identity Field to all entities

For every entity class (not value objects, not dependents):

  1. Always prefer a surrogate key (auto-assigned integer or UUID). Meaningful keys (email, SSN, order number) appear stable but fail in practice: human input errors break both uniqueness and immutability.
  2. Prefer simple (single-column) keys. They enable a Layer Supertype with uniform key handling. Compound keys require per-class handling and carry implicit meaning that tends to leak.
  3. Key type: 64-bit integer (BIGINT) is the best default — fast equality check, fast increment, effectively unlimited range. UUIDs/GUIDs provide database-wide uniqueness at the cost of larger index size and slower inserts (random insertion order).
  4. Inheritance caveat: With Class Table or Concrete Table Inheritance, keys must be unique across the hierarchy, not just per-table, to avoid Identity Map collisions.

*WHY:* The Identity Field is the bridge between the object graph and the relational schema. Without it, you cannot map FK references back to in-memory objects. Without surrogate keys, you inherit the fragility of the real world into your database contract.

Step 4 — Map relationships

Foreign Key Mapping (1:1 and N:1):

  • The FK column lives in the table of the class that holds the reference in memory.
  • For a collection (1:N), the FK lives in the child table (structural inversion: the parent holds a collection in OO, but the child table holds the FK in SQL).
  • Write order: insert parent first, then children, to satisfy FK constraints.

Association Table Mapping (N:M):

  • Create a link table with two FK columns (one per side).
  • The link table has no corresponding domain object and no Identity Field of its own.
  • Its PK is the compound of both FKs.
  • Treat the link table like a Dependent Mapping — delete all links for one side and re-insert on update.
  • If the association acquires its own attributes (role, start_date), promote the link table to a first-class entity with its own Identity Field and Foreign Key Mappings on both sides.

*WHY for Association Table:* There is no alternative for N:M in relational databases. Attempts to model N:M with a list-of-IDs column violate first normal form and make queries and updates extremely painful. Even if the association has no attributes today, using a join table preserves schema flexibility for when attributes appear.

Step 5 — Map child structures

Dependent Mapping:

  • Apply when: child object has no independent identity, is always loaded with its owner, and is never referenced by foreign keys from other tables.
  • The child class has no Identity Field, no Identity Map entry, and no independent finder methods.
  • The owner's mapper (or ORM cascade config) handles all inserts, updates, and deletes.
  • On update: delete all dependents for the owner, then re-insert (safe because no external FK references exist).
  • If another table needs a direct FK to the child, the child is not truly dependent — give it an Identity Field and use Foreign Key Mapping instead.

Embedded Value:

  • Apply to all DDD Value Objects (Money, Address, DateRange, GeoPoint, etc.).
  • Map each value field as a column on the owner's table (e.g., employment.salary_amount, employment.salary_currency).
  • The value class has no persistence methods of its own; the owner saves/loads it.
  • Do NOT use Embedded Value if: (a) the value is shared across multiple owners, (b) there can be a variable number of values per owner, or (c) you need to sort/filter on the value's fields via SQL independently of the owner.

*WHY for Embedded Value:* Value Objects have no identity and should never have their own table — a table of Money values or Address values is meaningless without context. Embedding them preserves the OO semantics (the value is part of the owner, not related to it) while avoiding extra joins and unnecessary tables.

Step 6 — Evaluate any graph / LOB candidates

For complex hierarchical or graph structures:

  1. Can the structure be represented with a self-referencing FK (e.g., parent_id on an organization table)? If yes, prefer this — it keeps data queryable.
  2. If the structure is truly too complex to normalize, and you are certain SQL will never need to filter or join on the internal fields, consider Serialized LOB.
  3. Choose format: JSON/JSONB (PostgreSQL, MySQL 5.7+) is preferred over XML for readability and tooling; binary BLOB is compact but opaque and fragile to class changes.
  4. Verify the anti-pattern checklist for Serialized LOB (see Key Principles).

*WHY:* Serialized LOB sacrifices SQL queryability for schema simplicity. This trade-off is acceptable for truly private, complex, non-queryable subgraphs. It is a trap when applied to data that reporting queries, search, or business logic will need to inspect.

Step 7 — Produce the structural mapping design document

For each entity and relationship, output:

[ClassName / Relationship]
  Pattern: <pattern name>
  Schema: <table/columns/constraints sketch>
  ORM config: <annotation or model field>
  Rationale: <why this pattern fits>
  Anti-pattern warning: <if applicable>

Review cross-cutting concerns:

  • Write ordering for inserts (parent before child for all FK relationships)
  • Cascade delete configuration (Dependent Mapping → cascade all; FK Mapping → decide per relationship)
  • Identity Map interaction (only entities with Identity Field enter the Identity Map; dependents and value objects do not)

Inputs

  • Domain model class list with relationships and cardinalities
  • Value object identification (which classes lack independent identity)
  • ORM stack and version
  • Existing schema (if mapping to a pre-existing database)
  • Any current LOB/JSON columns and the SQL queries that run against them

Outputs

A structural mapping design document containing:

  1. Pattern assignment table — every entity, value object, and relationship mapped to a pattern with rationale
  2. Schema sketch — table definitions (columns, types, FK constraints, join tables)
  3. ORM configuration — idiomatic annotations/model fields for the detected stack
  4. Write-order dependency graph — insert/update ordering to satisfy FK constraints
  5. Anti-pattern flags — any meaningful keys, LOB-queryability risks, or orphaned FK references identified

Output template (per structure):

## [Structure Name]
**Pattern:** [Pattern Name]
**Schema:**
  [table_name]([pk] BIGINT PK, [fk] BIGINT FK → [other_table.pk], [field] TYPE, ...)
**ORM:**
  [stack-specific annotation/field declaration]
**Rationale:** [1-2 sentences on why this pattern fits]
**Warning:** [if anti-pattern risk exists]

Key Principles

1. Surrogate keys over meaningful keys — always. Meaningful keys (SSN, email, order number) require uniqueness AND immutability from the real world, which human error and business rule changes routinely violate. Surrogate auto-assigned keys give you control over both. Fowler's framing: "take a rare stand on the side of meaninglessness."

2. Association Table Mapping is the only correct answer for N:M. Any attempt to encode a many-to-many with a list-of-IDs column violates first normal form and will make future queries impossible. Use a join table, even if the association has no attributes today — you will thank yourself when it acquires them.

3. Dependent Mapping requires no-external-FK discipline. A child object only qualifies as a dependent if no other table holds a FK reference to its table. The moment another entity needs a direct reference to the child, the child needs its own Identity Field and becomes a standalone entity mapped via Foreign Key Mapping.

4. All Value Objects should use Embedded Value. DDD Value Objects (Money, Address, DateRange) have no independent identity. Giving them their own table and Identity Field is wrong — it implies identity they don't have and adds joins where none are needed. The owner table absorbs their columns.

5. Serialized LOB is a trap for queryable data. The check is binary: will SQL ever need to filter, sort, or join on data inside the column? If yes, normalize it. PostgreSQL JSONB operators and XPath do not change this calculus — they are not portable and do not perform at scale like indexed normalized columns.

6. The structural inversion rule for 1:N. In OO, the parent holds the collection (album has tracks). In the relational model, the FK is on the child (track.album_id). This inversion is the source of most ORM confusion. The rule: the FK always lives on the "many" side of the relationship, regardless of which direction the OO association points.

7. When a join table acquires attributes, promote it to an entity. The moment a link table needs its own data (start_date, end_date, role, weight), it should become a first-class entity with its own Identity Field and explicit Foreign Key Mappings on both sides. This is a DDD relationship-as-entity promotion.

Examples

Example 1: E-Commerce Order Domain

Trigger: Team is designing the persistence layer for an order management system. Domain classes: Customer, Order, LineItem, Address (value object for shipping and billing).

Process:

  • Customer: entity → Identity Field (surrogate customer_id BIGINT)
  • Order: entity → Identity Field; references Customer → Foreign Key Mapping (order.customer_id FK → customers.customer_id)
  • LineItem: child with no independent identity, only exists within Order → Dependent Mapping (order_id, sequence composite PK or surrogate; cascade all)
  • ShippingAddress / BillingAddress: Value Objects → Embedded Value (columns shipping_street, shipping_city, shipping_zip, billing_street, etc. on the orders table)
  • Order ↔ Promotion (a customer's Order can use multiple Promotions, and a Promotion applies to multiple Orders): N:M → Association Table Mapping (order_promotions(order_id, promotion_id))

Output:

customers(customer_id BIGINT PK, name VARCHAR)
orders(order_id BIGINT PK, customer_id BIGINT FK, 
       shipping_street VARCHAR, shipping_city VARCHAR, shipping_zip VARCHAR,
       billing_street VARCHAR, billing_city VARCHAR, billing_zip VARCHAR)
line_items(line_item_id BIGINT PK, order_id BIGINT FK, product_id BIGINT FK, 
           quantity INT, unit_price DECIMAL)
order_promotions(order_id BIGINT FK, promotion_id BIGINT FK, PRIMARY KEY(order_id, promotion_id))

LineItem uses cascade-delete. ShippingAddress and BillingAddress are Embedded Value — no join needed to load them. Order↔Promotion uses a join table with no attributes (yet).


Example 2: Music Library with Dependent Tracks

Trigger: Mapping the Artist/Album/Track domain from PEAA Chapter 12.

Process:

  • Artist: entity → Identity Field (artist_id BIGINT)
  • Album: entity, references Artist → Identity Field + Foreign Key Mapping (album.artist_id FK → artists.artist_id)
  • Track: child of Album with no identity outside Album context; no other table references Track directly → Dependent Mapping. Album mapper loads/saves/deletes all Tracks. Track has no independent finder.
  • Track has no Identity Field; Album mapper deletes-and-reinserts all Tracks when Album is saved.

Output schema:

artists(artist_id BIGINT PK, name VARCHAR)
albums(album_id BIGINT PK, artist_id BIGINT FK, title VARCHAR)
tracks(album_id BIGINT FK, sequence INT, title VARCHAR, duration INT,
       PRIMARY KEY(album_id, sequence))

ORM (Hibernate): @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) on Album → tracks. Tracks loaded when Album is loaded.


Example 3: Legacy LOB Anti-Pattern Detection

Trigger: Existing system stores customer contact preferences as XML CLOB in the customers table. Support team needs to query "all customers who prefer email contact." Currently impossible via SQL.

Process:

  • Identify: customers.preferences_xml CLOB — a Serialized LOB.
  • Apply check: Do SQL queries need to filter on data inside the LOB? Yes — preferred_channel = 'email' must be queryable.
  • Verdict: Anti-pattern. Serialized LOB used for queryable data.
  • Recommendation: Normalize to a customer_preferences table: (customer_id BIGINT FK, preference_key VARCHAR, preference_value VARCHAR) or (customer_id, channel ENUM, enabled BOOLEAN). Apply Foreign Key Mapping.
  • Exception path: If the preference structure is complex and evolving AND a reporting-only database handles the queries, Serialized LOB with JSONB can remain in the operational DB while the reporting DB normalizes the structure.

References

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-inheritance-mapping-selector
  • clawhub install bookforge-data-access-anti-pattern-auditor

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

平台分布

OpenClaw

78.24%
按下载量换算933

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

通过

权限和风险

调用外部服务

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

安装前确认

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

继续浏览同类 Skills