i'm designing a database and run into some problems:
I have a Document
entity consisting of many fields. Mostly i want to use the same version of that document but sometimes users should be able to customize some of the fields for a specific usage of the document. Not customized fields should use the value of the parent document as a default. Changes to the parent document should get propagated to any not customized field of a specific usage.
I have a table Document
:
Document:
id | field1| field2 | field3| parentDocumentId
For parent documents is parentDocumentId = Null
. Customized usages of a document have the new value for the customized fields saved and for not customized fields simply null
.
Is this a good design?
Furthermore the Document
entity has a many-To-many relationship with another entity Course
. My problem now is when i look at a row of Document
with parentDocumentId != null
and courses = null
i can't determine if the relationship is either not customized by the user yet and i should use the value of the parent document or the field is customized by the user and simply has no courses
. How can i solve that?
Thanks
question from:
https://stackoverflow.com/questions/65649221/many-to-many-and-hierarchical-database-design 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…