model optimization.

I have a User model. Every User has a document. Then I have a Delegate model. User can have many delegates and one Delegate can have many users. Every Delegate has a document. Do you think it is better to create a Document model and put a one to one association to User and Delegate or put a document attribute in User and Delegate models?

Look how I understand that:

One User can be the owner of some document, the he can create many delegates and associate other users to that delegate. The delegate then give access to the document.

So the user that has a document, can share with others just by creating delegates to that document, right?

To further muddy the waters, are Delegates also Users in your system (similar to the "Manager is an Employee" problem)?

Msan Msan wrote in post #974585:

I have a User model. Every User has a document. Then I have a Delegate model. User can have many delegates and one Delegate can have many users. Every Delegate has a document. Do you think it is better to create a Document model and put a one to one association to User and Delegate or put a document attribute in User and Delegate models?

Do the simplest thing that could possibly work. In this case, that's probably just making document a field in Delegate. If that proves to be inadequate for your application logic, then refactor it to a separate model.

Best,

No, User are people who should be delivered bags, which can also be delivered to their representatives.

No, User are people who should be delivered bags, when delivered they must show a personal document to operator. Bags can also be delivered to their delegates, also the delegate must show a personal document.

Does a document have only one attribute at the present time? Could it reasonably be expected to have more at some point in the future? In that case I would probably model it separately.

It probably won't matter, though; I'd expect the amount of work to be the same with either approach.