Slight modification to PostgreSQL address table definition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey folks,

   I store all my userprefs and address books in PostgreSQL, and
I've run into a problem occasionally with the constraint suggested
in the documentation found at:

http://www.squirrelmail.org/docs/admin/admin-5.html#db-backend

   It suggests creating the address table with the following
definition:

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");

   Unfortunately, that unique index is too narrow - I cannot have more
than one user that defines an address with "Frank" and "Marshall" as
their names, for example.  I would instead suggest a constraint
like so:

CREATE UNIQUE INDEX "address_firstname_key" ON "address" ( "firstname",
   "lastname", "owner", "email" );

   This allows multiple users to have identical entries, which may
or may not fit your needs.  It does mine.  :)  Having a four-column
unique index may produce index bloat on larger installations, I have
less than a thousand addresses in mine and it works great.

Benny


-- 
"Well, we *could* hunt down the perpetrators, pool some $$, and
hire 3 or 4 baseball-bat wielding professional explainers to go
explain our position to them.  Figuring out how to do so without
breaking any laws is the tough part..."
                                 -- Valdis Kletnieks, 2009-01-23



------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
-----
squirrelmail-users mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-users@xxxxxxxxxxxxxxxxxxxxx
List archives: http://news.gmane.org/gmane.mail.squirrelmail.user
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-users


[Index of Archives]     [Video For Linux]     [Yosemite News]     [Yosemite Photos]     [gtk]     [KDE]     [Cyrus SASL]     [Gimp on Windows]     [Steve's Art]     [Webcams]

  Powered by Linux