I was looking at ER diagrams today. If we consider two entities, Item and Member in the context of a rental shop, the member can either checkout an item or renew the item. So for this, I came up with the following:
The idea was that a member can check out any number of items but an item can be checked out only once. And, a member can renew any number of items and an item can be renewed by only one member. But my problem is that once a member renews an item, do I need to explicitly indicate it in the ER diagram somehow? I mean, lets say I renew an item, how do I indicate that it should be updated in the CHECKOUT_LOG
table or is it开发者_开发问答 specific only to the relational model?
Have you considered that a renewal and checkout are essentially the same function. From your commentary I see two differences.
- Checkout occurs only if the user does not already have the item.
- Renewal updates the last_renewal (derivable from theckout log).
As modeled a member can't return an item and then check it out again.
I would model as three entities (primary key in parenthesis.
Item: (Item_id), other fields Member: (User_Id), other fields Checkout: (Item_id, User_Id, Created Timestamp), Return Date, Renewal Indicator
精彩评论