开发者

SQL Schema - Default of 1:Many

How can I specify the default value of a 1:Many relationship ... for example take a user that has 5 phone numbers ... I need to record the "preferred" phone number. Should I use an attribute on the phone_number record to indicate the preferred one - or have a attribute of the user record (preferred_phone_nu开发者_运维知识库mber for example) that is the primary key from the phone_numbers table ?

Thanks


  1. User.preferred_phone: you have zero or one preferred numbers per user.

  2. Phone.is_preferred: you may have any amount of preferred numbers per user, without a way to choose the 'most preferred', and even 'preferred numbers' that no user relates to.

So I'd clearly stick with #1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜