library icon indicating copy to clipboard operation
library copied to clipboard

Is the storage of the Book attributes redundant?

Open Michael1024-CJX opened this issue 2 years ago • 1 comments

The values of some fields of BookDatabaseEntity are always the same, such as "available_at_branch" and "on_hold_at_branch" and "checked_out_at_branch", "on_hold_by_patron" and "checked_out_by_patron".

I can understand that these attributes have different meanings in the domain. but in terms of storage, is it feasible to map attributes with the same value to the same field, so that the number of fields can be reduced? For example, use "branch_id" and "patron_id".

class BookDatabaseEntity {
    UUID book_id;
    BookType book_type;
    BookState book_state;
    Instant on_hold_till;
    UUID branch_id;
    UUID patron_id;
    int version;
}

We can still judge the meaning of branch_id and patron_id through book_state.

Michael1024-CJX avatar Nov 22 '21 13:11 Michael1024-CJX

Can you explain the benefits of this redundant field design, there are many scenarios where this same value can be expressed as an attribute of different domain concepts?

Michael1024-CJX avatar Nov 22 '21 13:11 Michael1024-CJX