Menu

Add unique index on table domain_admins?

Anonymous
2011-01-27
2013-01-23
  • Anonymous

    Anonymous - 2011-01-27

    Hi, developers.

    I'm using PostfixAdmin-2.3.2, the default structure of table 'domain_admins' in upgrade.php is:

        CREATE TABLE {IF_NOT_EXISTS} $domain_admins (
          `username` varchar(255) NOT NULL default '',
          `domain` varchar(255) NOT NULL default '',
          `created` datetime NOT NULL default '0000-00-00 00:00:00',
          `active` tinyint(1) NOT NULL default '1',
          KEY username (`username`)
        ) {MYISAM} COMMENT='Postfix Admin - Domain Admins';";

    I was wondering why not add a unique key (or primary key) to avoid duplicate records? like this:

    PRIMARY KEY (username, domain)

    Otherwise we can insert multiple records like this:

    INSERT INTO domain_admins (username, domain) values ('xxx@xxx', 'domain.ltd');
    INSERT INTO domain_admins (username, domain) values ('xxx@xxx', 'domain.ltd');
    INSERT INTO domain_admins (username, domain) values ('xxx@xxx', 'domain.ltd');

     
  • Anonymous

    Anonymous - 2011-02-05

    Any comments?

     
  • Chris H.

    Chris H. - 2011-02-05

    seems like a pretty solid idea to me.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.