Prerequisites
I have three entities: Record, Header, and Row.
Record:
- id
- index
- date
- children (one-to-many relationship with Header entities)
Header:
- id
- index
- title
- parent (Record) (Is null if this Header is a subheader)
- headerParent (Header) (Is null if this Header is not a subheader)
- subheaders (one-to-many relationship with Header entities)
- children (one-to-many relationship with Row entities)
Row:
- id
- index
- title
- value
- parent (Header)
Issue
I need to have default data in these entities. When creating a new Record, I want it to copy all default entity data (except for the Row's value) to generate a new Record ready for new notes. Additionally, if the order (index) of the entities' data or their titles are updated, I want the default data to update automatically so the user doesn't have to make these changes manually every time.
Proposed Solution
My approach is to add a field called isBaseEntity to each entity. When isBaseEntity is true, this entity contains the default information. I would then update this base entity with any changes made to the non-base ones. Additionally, I would exclude this base entity when fetching the rest of the data, as it serves as the default template.
Question
Is this a good and efficient approach? Do you have any other suggestions or recommendations for improving this?
I would really appreciate any help you can provide.