Got three entities -
- User - Has username/password, contact information, billing information etc.
- Periodical - Has periodical_name, category, publisher_info, print_cycle, unit_price etc.
- Subscription - Has the user-id, periodical-id, subscription start/end date, status etc.
And following relationships -
- User can have Subscription for multiple Periodicals.
- Subscription belongs-to a User, and has-a Periodical associated.
- Periodical has-many Subscriptions associated with it.
s.t.,
- User--Subscription relation is One-to-Many,
- Periodical--Subscription relation is One-to-Many,
My questions --
Is this model description correct for the real-world relationships typically found ?
Or, am I better off, collapsing Periodical into Subscription, especially if per Periodical information is not extensive and can be encoded into, say a delimiter separate text field (e.g. "PeriodicalName:Frequency:Publisher:UnitPrice") ?
Can I say that via associativity User--Periodical relation is Many-to-Many ?
Would appreciate if someone can show how I could put a constraint around either User or Subscription table (assuming that I don't collapse Subscription & Periodical), s.t. when a User needs to be removed for some reason, all associated Subscriptions are deleted too.
Would like to keep a User record around for sometime (say a year), even after all Subscriptions have expired, so I guess I can assign NULL to the FK subscription_id in User table, right ? This is when no corresponding record exists in Subscription table.