Schema Design Guide¶
Placeholder — content to be migrated and expanded from
../schema-design-guide.md.
This guide describes how to define your domain's entities, relationships, and documents using kgschema.
Domain schema¶
Implement DomainSchema from kgschema.domain to declare:
- Entity types — map type names to
BaseEntitysubclasses. - Relationship types — map predicate names to
BaseRelationshipsubclasses. - Document type — the
BaseDocumentsubclass for your input format. - Promotion config — thresholds for provisional → canonical promotion.
Entities¶
- Subclass
BaseEntity. - Implement
get_entity_type(). - Use
EntityStatus:canonicalorprovisional. - All fields must have
description=strings (enforced by convention).
Relationships¶
- Subclass
BaseRelationship. - Declare
subject_typeandobject_typeto constrain valid endpoints. - Include a
predicatefield with a controlled vocabulary from your domain.
Documents¶
- Subclass
BaseDocument. - Include fields for document metadata: identifier, title, publication date, source.
- The parser produces one
BaseDocumentper input file.
Immutability¶
Schema models should use model_config = ConfigDict(frozen=True). This prevents
accidental mutation and makes models safe to use as dict keys or in sets.