doulei1965 2010-06-04 21:58
浏览 30
已采纳

帮助php / mysql邮件程序

I'm working on a real estate site and need to make notification mailer: when new property is inserted on a site, people who subscribed for notification in that particular country and/or area and/or city and/or particular property operation (rental, selling) will receive a notification on email. One person could subscribe for different areas, cities, etc, not only one. One person will receive only one notification a week let say if there are new properties for him, though. And I'm thinking on how better to create a mysql table for subscribers in order to easy retrieve them. Table like:

create table subscribers(
user_email varchar(255),
area_id int(4));

is a bad idea, because if there will be let say 100,000 (looking to the future) subscribers and each will subscribe for 10 areas there will be 1,000,000 rows in a table. So, I'm looking for efficient solution to do such task.

If you have additional recommendations, I will like to hear them.

Thanks in advance!

  • 写回答

4条回答 默认 最新

  • duanrebo3559 2010-06-04 22:09
    关注

    You should use a cross-reference (many-to-many) table. This will make data more normalized:

    CREATE TABLE `areas` (
      `id` int(10) unsigned NOT NULL auto_increment,
      `name` varchar(255) NOT NULL
      PRIMARY KEY  (`id`)
    )
    
    
    CREATE TABLE `subscribers` (
      `id` int(10) unsigned NOT NULL auto_increment,
      `email` varchar(255) NOT NULL
      PRIMARY KEY  (`id`)
    )
    
    
    -- cross ref table
    CREATE TABLE `areas_subscribers` (
      `area_id` int(10) unsigned NOT NULL,
      `subscriber_id` int(10) unsigned NOT NULL,
      UNIQUE KEY (`area_id`,`subscriber_id`)
    )
    

    And a million rows is not a problem. Especially with a cross ref table.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作