Replies: 2 comments 1 reply
-
|
Just a quick comment on the O(n) point in the cons section: Gramps already maintains a relation table that effectively forms a graph There has been some discussion in other parts of the project about using To really utilize the relation table for speed, graph logic and graph algorithms should be considered. Semi-related comment: One additional point worth considering: The current relation table is very flexible, but it also has to carry all This would also make graph-based traversal more efficient, since each Note: it might be I come with some more comments later, but as I read this Design Plan today, it is more or less picked out of my brain with a spoon... the Sun is shining right now... |
Beta Was this translation helpful? Give feedback.
-
There is already an index on event handles, so not sure what the AI is talking about there.
Yes, I having been following that, and in fact created the first "business logic" methods in the database layer that can be implemented by the database (such as SQL). But I stuck to current Grampic philosophies for this plan. I think we can talk about the basic implementation without requiring a re-write of the Gramps DB.
Yes, I considered that. But I believe that if we do it, we should do it for all such relationships, not just for one in this plan. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a proposal for implementing the idea of super- and sub- events. I've tried to capture many of the ideas of the following conversations:
and others as well. If we can come to consensus on this, we can begin development.
Overview
Items marked "deferred" will be addressed in Phase 5.
Problem Statement
Gramps currently models events as a flat list. Every event — whether a single
birth, a multi-year military campaign, or an entire national census — sits at
the same level. There is no way to express that one event is a component of a
larger event, or that a set of events forms a meaningful group.
This creates real research problems:
events with no structural link between them. Finding all the legs of one
journey requires manual searching or complex filters.
represented as a hierarchy — everything ends up in one undifferentiated list.
internal structure that Gramps currently cannot capture.
The feature request from the community asks for sub-events: the ability to
attach an event to one or more "super-events", so that events can be browsed
and understood as a hierarchy rather than a flat list.
Motivating Example
A researcher documents an 1882 emigration from Rinteln, Germany to Prineville,
Oregon. The journey takes 84 days and involves many discrete steps:
Later, the researcher finds two other families who also sailed on the
Montebello from Bremen with Oregon as their destination. Their journey took 103
days — 20 more than expected. By examining all events linked to the place "D/S
Montebello", the researcher discovers the unplanned stop in Hull. That stop is
registered as a sub-event of "Montebello Journey 1882", linked to the place
Hull, England — and because that voyage event is already linked to the place
"D/S Montebello", the Hull stop appears naturally under both the Emigration
hierarchy and under a separate "Ship Journeys" hierarchy the researcher has
also built.
This is the capability the feature must support.
Terminology
The words parent and child are deliberately avoided. In a genealogy
application those words refer to people, and using them for events would create
confusion in both UI labels and in conversation.
The community discussions naturally use "main event" and "sub-event".
We adopt these terms for user-facing labels and introduce "super-event" as
the precise technical counterpart to "sub-event" (it simply means "above in the
hierarchy" with no genealogical connotation).
super_event_listKey Design Decisions
1. List of super-events, not a single handle
An event can belong to more than one super-event hierarchy at the same
time. In the emigration example, the Montebello voyage event belongs to both
the "Emigration 1882" hierarchy and an independently maintained "Ship Journeys"
hierarchy. A single optional handle cannot represent this.
The field is therefore
super_event_list: list[EventHandle]— a list of zeroor more handles to super-events.
This mirrors the Place model exactly. Places already support multiple
parent places through
placeref_list, allowing a village to appear in morethan one administrative hierarchy (civil parish and ecclesiastical parish, for
example). Sub-events follow the same pattern.
2. Plain handle list, not a wrapper object
Gramps'
PlaceRefsecondary object wraps a handle plus a validity date becausea place has no date of its own. A village might belong to one county in 1800
and a different county after a border change in 1850, so the relationship between
places needs its own date to capture that.
Events already have a date. A sub-event's own date already says when it
occurred; the relationship between a sub-event and its super-event carries no
additional temporal information that is not already on the event itself.
Using a plain
list[EventHandle]keeps the implementation simple and avoidsintroducing a new secondary-object class.
3. Reference stored on the sub-event, not the super-event
Each sub-event stores the handles of its super-events. The super-event does
not store a list of its sub-events. This is the same direction as
placeref_list(each Place stores its parent Places, not the other way around).
Pros:
machinery — the sub-event's list is updated automatically.
leaving orphaned forward-references.
is acceptable at current Gramps database sizes. An index can be added later
if performance becomes a concern.
Cons:
For very large databases (>100 000 events) this may be slow. Mitigation: add
a secondary index in the database backend at the same time, or defer until
needed.
4. DAG, not a strict tree
Because an event can have multiple super-events, the structure is a
directed acyclic graph (DAG), not a simple tree. The hierarchy view must
handle events that appear under more than one node. Cycles (an event being its
own ancestor) are forbidden and must be checked at save time.
Implementation Plan
Phase 1 — Data Model
gramps/gen/lib/event.pysuper_event_list: list[EventHandle]field, initialized to[].serialize()— append the new field as the last element of the tuple(keeps all existing serialized data valid).
unserialize()— if the field is absent (data from an older Grampsversion), default to
[].get_schema()with the new field definition._has_handle_reference(),_remove_handle_references(),_replace_handle_reference(), andget_referenced_handles()to cover everyhandle in
super_event_list— so that deleting a super-event automaticallyremoves it from all sub-events' lists.
gramps/gen/types.pyEventHandleis exported (expected, no change likely needed).Phase 2 — Database Migration
gramps/gen/db/generic.pyVERSIONfrom(22, 0, 0)to(23, 0, 0).get_sub_events(handle: EventHandle) -> list[Event]— queries all eventsand returns those whose
super_event_listcontains the given handle.gramps/gen/db/upgrade.pygramps_upgrade_23(): iterate all raw event records and append[](empty super-event list) to each serialized tuple. Standard no-op migration
to bring existing data to the new schema shape.
Phase 3 — Editor UI
gramps/gui/editors/editevent.py(the same pattern as
PlaceRefEmbedList), since an event can belong tomultiple super-events and the researcher may want to set a manual order when
dates alone are not enough to distinguish sequence.
button opens the existing
SelectEventdialog to choose one.selected super-event is already a descendant of the current event.
gramps/gui/editors/editevent.gladePhase 4 — Events Tree View
gramps/plugins/view/eventview.pyHierarchy view.
TreeStoreinstead ofListStore.super_event_list.super_event_listincludes that node'shandle.
gramps/gui/views/treemodels/eventmodel.pyPhase 5 — Gramplets and Reports (deferred)
Narrative and graphical reports that iterate events are unaffected in Phase 1 —
they already show all events. Future follow-up work can:
sub-events inline.
File Change Summary
gramps/gen/lib/event.pysuper_event_listfield; serialize/unserialize; handle-ref methodsgramps/gen/types.pyEventHandleexported (likely no change)gramps/gen/db/generic.pyget_sub_events()methodgramps/gen/db/upgrade.pygramps_upgrade_23()migrationgramps/gui/editors/editevent.pygramps/gui/editors/editevent.gladegramps/plugins/view/eventview.pygramps/gui/views/treemodels/eventmodel.pyTreeStoresupport for hierarchy modePros and Cons of the Overall Approach
Pros
Gramps developers and users already understand
placeref_list;super_event_listfollows identical conventions, keeping the codebase consistent.
defaults to
[]. All existing data is valid. No existing behaviour changes.an Emigration hierarchy and a Ship Journeys hierarchy without duplication.
tables. No changes to the plugin system.
Users who never use sub-events see no difference.
Cons
scanning all events. For very large databases this could be slow. A secondary
index would fix this but is deferred.
multiple nodes) in a GTK
TreeStorerequires duplicating rows, which canbe confusing if not clearly signalled in the UI.
walking the chain, which is also O(depth). Depth is expected to be small in
practice (single digits), so this is not a concern in practice.
structure until follow-up work is done. This is a known gap, not an
oversight.
Beta Was this translation helpful? Give feedback.
All reactions