翻阅了一下旧帖子,还是没看太懂,只好发新帖求教。非计算机专业MySQL自学菜鸟,问题比较幼稚,见笑~就是需要做一个人员信息数据库,光一个persons.email不够用,因为很多人都有第二个Email,甚至第三个。这种情况下,是设置persons.email1, persons.email2,还是得用什么别的处理方式,才符合范式要求?如果单独建立一个emails表,再用personID做外链,那是不是就太太太麻烦了啊。

解决方案 »

  1.   

    it depends.If you know you will query against emails addresses, you'd better have either separate column or separate table. Otherwise, if the extra email is only some sort of notes, leave them in one column is fine...
      

  2.   

    你说 separate column,就是设置两个以上的Email字段吗?那岂不是不符合第二范式了?在同一个字段里放两个Email肯定不行啊,因为以后还指着便捷发邮件呢 单独设置表又觉得太麻烦了。难道就没有更好的办法吗。。
      

  3.   


    who care NF. I am not a DBA but I know most of my DBA don't care NF at all and I don't give a shit to that anyway...you don't want to go for the separate table and you also want to keep your NF compliant...You know you can't have both, what do you want anyway?If storing email is for notification only, put them in one column with the delimiter and let the application takes care others. That sounds good to you?I know, you also will be the programmer. so you don't want to take the extra burden that is supposed to be taken care of by the database, right?Then we come back to the origin...
      

  4.   

    如果不超过三个,方便你的后面的程序开发,建议加多个 mail1, mail2, mail3 字段即可。 虽然有些浪费空间,和查询时会需要用 一些冗余,但对初学者比较方便。比较IT正统的数据库范式要求,则是另外创建一个通信方式表 
    (user id, 通信方式, 联络信息)张三, mail, [email protected]
    张三, mail, [email protected]
    张三, mobilephone, +86 10 13812345678
    ....
      

  5.   

    感谢各位慷慨解答!
    特别感谢 ACMAIN_CHM 的解释,很清楚!