MBF Knowledge Base

How to Store address books in the database

Create a table for the address books. The table structure should be similar to this for MySQL:

    CREATE TABLE address (
      owner varchar(128) DEFAULT '' NOT NULL,
      nickname varchar(16) DEFAULT '' NOT NULL,
      firstname varchar(128) DEFAULT '' NOT NULL,
      lastname varchar(128) DEFAULT '' NOT NULL,
      email varchar(128) DEFAULT '' NOT NULL,
      label varchar(255),
      PRIMARY KEY (owner,nickname),
      KEY firstname (firstname,lastname)
    );

and similar to this for PostgreSQL:

    CREATE TABLE "address" (
      "owner" varchar(128) NOT NULL,
      "nickname" varchar(16) NOT NULL,
      "firstname" varchar(128) NOT NULL,
      "lastname" varchar(128) NOT NULL,
      "email" varchar(128) NOT NULL,
      "label" varchar(255) NOT NULL,
      CONSTRAINT "address_pkey" PRIMARY KEY ("nickname", "owner")
    );
    CREATE UNIQUE INDEX "address_firstname_key" ON "address"
      ("firstname", "lastname");

Don't forget to configure SquirrelMail with the DSN and the table name. This can be done using either

the SquirrelMail configuration utility or via the administration plugin. The global address book uses

same table format as the personal address books. You can even use same table if you don't have a

user named "global", but that's not recommended.