NASA-AMMOS / NASA-AMMOS/plandev
Consider adding foreign key relationships between activity types, directives, and spans
Open
Nobody has claimed this yet.
feature
- Dominant language
- Java
- Stars
- 128
- Forks
- 33
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 12
Description
activity_directivetable should be foreign key constrained to theactivity_typetable to enforce that activity directives have valid activity typesspantable should be foreign key constrained toactivity_directivetable to enforce that any given span is a valid activity directive (unless the span is a child activity in which case the foreign key will benull)- A span associated with an activity directive already has a weak relationship to the
activity_directivetable via a property in the jsonbattributescolumn calleddirectiveId. This relationship should be codified in the database with foreign key constraints to enable proper joins and elucidate the relationship.
- A span associated with an activity directive already has a weak relationship to the
Some considerations per @mattdailis:
- Performance. Creating a foreign key relationship requires an index which could slow things down if you are writing since index updating can be expensive.
- We should not be deleting spans when we delete an associated activity directive since spans can be viewed in historic simulation data. Does adding a foreign key require deleting a span when deleting the associated activity directive?
Transferred Internal Tickets:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or entry points are named. Start by locating the schema definitions for the activity_type, activity_directive, and span tables, then inspect how directiveId is stored in span.attributes. Done means the relationships are enforced, child-activity spans can retain a null relationship, and deleting an activity directive does not delete historical spans.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100