I was wondering if there was such thing as 'belongs to' relationship, and what was its function, or if it was just the opposite to 'has one'?
The question arised when building an ORM, and wanted to find a way to determine when a entity instance should be automatically deleted, eg:
User 'has many' Thread
Thread 'has many' Comment
Thread 'has one' User
Comment 'has one' Thread
Suppose you delete a user instance. Its related thread instances should remain intact. But if you delete a thread instance, its comments should be deleted.
With the above schema, the ORM can't tell when to delete and when not to. But if I use 'belong to', it could be a solution:
User 'has many' Thread
Thread 'has many' Comment
Thread 'has one' User
Comment 'belongs to one' Thread
Does this make sense? It is possible for the ORM, but does ERD cover this scenario? The one-to-one/one-to-many connections don't seem to be enough.
Any thoughts?