Enforcing uniqueness on [real estate/postal] addresses

Поиск
Список
Период
Сортировка
Искать
От
Peter Devoy
Тема
Enforcing uniqueness on [real estate/postal] addresses
Дата
в 16:55:49
Msg-id
CABoFc_im50V4DgcOddDiPyDWEFkVR==P26q8fBLNdgcpx--rSw@mail.gmail.com
Список
Дерево обсуждения
Enforcing uniqueness on [real estate/postal] addresses Peter Devoy <peter@3xe.co.uk>
Re: Enforcing uniqueness on [real estate/postal] addresses Tim Cross <theophilusx@gmail.com>
Re: Enforcing uniqueness on [real estate/postal] addresses "Peter J. Holzer" <hjp-pgsql@hjp.at>
Re: Enforcing uniqueness on [real estate/postal] addresses Peter Devoy <peter@3xe.co.uk>
Re: Enforcing uniqueness on [real estate/postal] addresses Adrian Klaver <adrian.klaver@aklaver.com>
Re: Enforcing uniqueness on [real estate/postal] addresses Karsten Hilbert <Karsten.Hilbert@gmx.net>
Re: Enforcing uniqueness on [real estate/postal] addresses "Peter J. Holzer" <hjp-pgsql@hjp.at>
Re: Enforcing uniqueness on [real estate/postal] addresses Rich Shepard <rshepard@appl-ecosys.com>
RE: Enforcing uniqueness on [real estate/postal] addresses "Basques, Bob (CI-StPaul)" <bob.basques@ci.stpaul.mn.us>
Re: Enforcing uniqueness on [real estate/postal] addresses David Goodenough <david.goodenough@broadwellmanor.co.uk>
RE: Enforcing uniqueness on [real estate/postal] addresses Rich Shepard <rshepard@appl-ecosys.com>
RE: Enforcing uniqueness on [real estate/postal] addresses "Basques, Bob (CI-StPaul)" <bob.basques@ci.stpaul.mn.us>
Re: Enforcing uniqueness on [real estate/postal] addresses Paul Jungwirth <pj@illuminatedcomputing.com>
Re: Enforcing uniqueness on [real estate/postal] addresses Peter Devoy <peter@3xe.co.uk>
Re: Enforcing uniqueness on [real estate/postal] addresses Adrian Klaver <adrian.klaver@aklaver.com>
Re: Enforcing uniqueness on [real estate/postal] addresses "David G. Johnston" <david.g.johnston@gmail.com>
Re: Enforcing uniqueness on [real estate/postal] addresses Philip Semanchuk <philip@americanefficient.com>
Hi list

I need to store addresses for properties (as in real estate) so in my
naivety I created a unique constraint like this:

ALTER TABLE properties
    ADD CONSTRAINT is_unique_address
    UNIQUE (
        description, --e.g. Land north of Foo Cottage
        address_identifier_general,
        street,
        postcode
    );

Of course, if any of the fields are NULL (which they often are) I end
up with duplicates.

One solution may be to add NOT NULL constraints and use empty strings
instead of NULL values but, until asking around today, I thought this was
generally considered bad practice.

Please can anyone recommend a way of approaching this? Perhaps empty strings
are pragmatic in this situation?

Kind regards


Peter


В списке pgsql-general по дате отправления
От: Laurenz Albe
Дата:
От: Philip Semanchuk
Дата:
FAQ